Skip to content

Parse uri= simplified format for open-issue-webview links#8775

Merged
alexr00 merged 2 commits into
mainfrom
copilot/fix-link-to-issue
Jun 10, 2026
Merged

Parse uri= simplified format for open-issue-webview links#8775
alexr00 merged 2 commits into
mainfrom
copilot/fix-link-to-issue

Conversation

Copilot AI commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Issue links emitted by VS Code chat (via microsoft/vscode#320404) use a simplified ?uri=… query, e.g.

vscode-insiders://github.vscode-pull-request-github/open-issue-webview?uri=https://github.com/microsoft/vscode-tools/issues/964

fromOpenIssueWebviewUri only understood the legacy JSON-encoded query and returned undefined, so the URI handler silently dropped the click.

Changes

  • src/common/uri.tsfromOpenIssueWebviewUri now first attempts to parse a uri=https?://github.com/<owner>/<repo>/issues/<n> query parameter (anchored regex rejects extra path segments and non-numeric numbers), then falls back to the legacy JSON format. Mirrors the existing fromOpenOrCheckoutPullRequestWebviewUri shape.
  • src/test/common/uri.test.ts – Adds coverage for the new format, http variant, JSON fallback, invalid authority/path/host, non-numeric numbers, and trailing path segments.

Copilot AI linked an issue Jun 8, 2026 that may be closed by this pull request
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix hyperlink issue for issue number in chat Parse uri= simplified format for open-issue-webview links Jun 8, 2026
Copilot AI requested a review from alexr00 June 8, 2026 13:26
@alexr00 alexr00 marked this pull request as ready for review June 9, 2026 10:46
Copilot AI review requested due to automatic review settings June 9, 2026 10:46
@alexr00 alexr00 enabled auto-merge (squash) June 9, 2026 10:46
@alexr00 alexr00 disabled auto-merge June 9, 2026 10:46

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.

Pull request overview

This PR updates the extension’s URI parsing so that “open issue” links emitted by VS Code chat using the simplified ?uri=… query format are correctly recognized, instead of being silently dropped by the URI handler.

Changes:

  • Extend fromOpenIssueWebviewUri to parse the simplified uri=https?://github.com/<owner>/<repo>/issues/<n> query format, with strict URL validation, and fall back to the legacy JSON query format.
  • Add unit tests covering the new simplified format, legacy JSON fallback, and multiple invalid-input cases.
Show a summary per file
File Description
src/common/uri.ts Adds simplified uri= query parsing for issue-webview links before falling back to legacy JSON parsing.
src/test/common/uri.test.ts Adds coverage for simplified-format issue URIs and validation/compatibility cases.

Copilot's findings

Comments suppressed due to low confidence (1)

src/common/uri.ts:729

  • In the legacy JSON fallback, JSON.parse returns any, so issueNumber might be a string (or other non-integer) even if validateOpenWebviewParams passes. Returning query directly can leak an unexpected type into downstream code that assumes issueNumber: number (e.g. uriHandler.ts passes it as identity.number). Coerce and validate issueNumber as a safe integer before returning, and return a strongly-typed object.
		const query = JSON.parse(uri.query.split('&')[0]);
		if (!validateOpenWebviewParams(query.owner, query.repo, query.issueNumber)) {
			return;
		}
		return query;
  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@alexr00 alexr00 merged commit beb381e into main Jun 10, 2026
7 checks passed
@alexr00 alexr00 deleted the copilot/fix-link-to-issue branch June 10, 2026 09:21
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.

Link to an issue doesn't work

4 participants