Skip to content

Normalize URI-valued DocumentIdentifier inputs - #65646

Open
Andrew Branch (andrewbranch) wants to merge 2 commits into
microsoft:mainfrom
andrewbranch:normalize-document-identifier-uris
Open

Andrew Branch (andrewbranch) wants to merge 2 commits into
microsoft:mainfrom
andrewbranch:normalize-document-identifier-uris

Conversation

@andrewbranch

@andrewbranch Andrew Branch (andrewbranch) commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #65591:
#65591 (comment)
#65591 (comment)

DocumentIdentifier.UnmarshalJSONFrom casts URI strings directly to lsproto.DocumentUri, bypassing its normalization and validation. Instead, delegate to (*lsproto.DocumentUri).UnmarshalJSONFrom to do the proper URL parsing and validation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The URI parser double-encodes escaped opaque file paths, causing document identifiers to resolve to the wrong filename.

1 open issue
What changed in this PR

This follow-up to #65591 aligns URI-valued API document identifiers with the language server’s URI normalization and validation.

Changes:

  • Delegate URI-object decoding to DocumentUri, leaving plain filename strings unchanged.
  • Normalize single-slash file URIs to the canonical file:/// form.
  • Add Go and TypeScript API tests for normalization, validation, and module resolution.
File Description
tsc/​internal/​lsp/​lsproto/​lsp.go Normalize file URI host formatting.
tsc/​internal/​lsp/​lsproto/​lsp_json_test.go Test single-slash and escaped file URIs.
tsc/​internal/​api/​proto.go Use shared URI decoding for document identifiers.
tsc/​internal/​api/​proto_test.go Cover URI normalization, invalid inputs, and resolved paths.
packages/​typescript/​test/​sync/​api.test.ts Test synchronous resolution with equivalent URI forms.
packages/​typescript/​test/​async/​api.test.ts Test asynchronous resolution with equivalent URI forms.

Review effort: Balanced

Comment thread tsc/internal/lsp/lsproto/lsp.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the URI-valued document identifier normalization changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

This branch has not been deployed

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

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants