Skip to content

Iri#issue#195

Open
bourgeoa wants to merge 3 commits intomainfrom
iri#issue
Open

Iri#issue#195
bourgeoa wants to merge 3 commits intomainfrom
iri#issue

Conversation

@bourgeoa
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings February 12, 2026 15:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates type index URL suggestion logic to better handle WebIDs / documents where doc().dir() can’t be derived, and adds extra logging around current-user selection in authn.

Changes:

  • Add docDirUri() helper and update suggestPublicTypeIndex / suggestPrivateTypeIndex to use it (with error handling).
  • Adjust loadTypeIndexesFor to avoid creating type index links when a suggested location can’t be derived.
  • Add additional debug.log statements in SolidAuthnLogic.currentUser().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/typeIndex/typeIndexLogic.ts Adds directory-derivation helper and changes how public/private type index suggestions are computed and used.
src/authn/SolidAuthnLogic.ts Adds verbose logging for which WebID source is used by currentUser().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +138 to +143
const lastSlash = withoutFragment.lastIndexOf('/')
if (lastSlash === -1) {
debug.log(`docDirUri: no slash in doc uri ${docUri}`)
return null
}
return withoutFragment.slice(0, lastSlash + 1)
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docDirUri’s string-splitting fallback can return an invalid directory for WebIDs whose doc URI has no path beyond the origin (e.g. https://example.com#me => https://). In that scenario suggest*TypeIndex will build an invalid URL and may even write bad links. Use URL parsing instead (e.g. derive the directory via new URL('.', docUriWithoutFragment).toString() and ensure origin-only URIs map to origin + '/').

Suggested change
const lastSlash = withoutFragment.lastIndexOf('/')
if (lastSlash === -1) {
debug.log(`docDirUri: no slash in doc uri ${docUri}`)
return null
}
return withoutFragment.slice(0, lastSlash + 1)
try {
const docUrl = new URL(withoutFragment)
const dirUrl = new URL('.', docUrl)
const dirUri = dirUrl.toString()
// Ensure origin-only URIs map to "origin + '/'" (e.g. https://example.com -> https://example.com/)
if (dirUrl.origin && (dirUrl.pathname === '' || dirUrl.pathname === '/')) {
return dirUrl.origin + '/'
}
return dirUri
} catch (e) {
debug.log(`docDirUri: invalid doc uri ${docUri}`, e)
return null
}

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this case never appears. So no need to change code

@bourgeoa bourgeoa requested a review from timea-solid February 13, 2026 11:07
Copy link
Member

@timea-solid timea-solid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great.

Comment on lines +138 to +143
const lastSlash = withoutFragment.lastIndexOf('/')
if (lastSlash === -1) {
debug.log(`docDirUri: no slash in doc uri ${docUri}`)
return null
}
return withoutFragment.slice(0, lastSlash + 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this case never appears. So no need to change code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants