Skip to content

Commit ad87153

Browse files
committed
ignore unrecognized URIs
If a document has a URI other than `git:` (such as `comment:`, `https:`, etc., which occur in new experimental Sourcegraph features), the following error appears in the browser JS console: ``` Uncaught (in promise) Error: unrecognized URI: "comment://2" (supported URI schemes: git) ``` This change suppresses that error by skipping the attempt to decorate such files.
1 parent 18c9a14 commit ad87153

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: src/extension.ts

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export function activate(): void {
2323
}
2424

2525
const uri = resolveURI(editor.document.uri)
26+
if (!uri) {
27+
return
28+
}
2629

2730
const threads = await fetchDiscussionThreads({
2831
first: 10000,

Diff for: src/uri.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Resolve a URI of the forms git://github.com/owner/repo?rev#path and file:///path to an absolute reference, using
33
* the given base (root) URI.
44
*/
5-
export function resolveURI(uri: string): { repo: string; rev: string; path: string } {
5+
export function resolveURI(uri: string): { repo: string; rev: string; path: string } | null {
66
const url = new URL(uri)
77
if (url.protocol === 'git:') {
88
return {
@@ -11,5 +11,5 @@ export function resolveURI(uri: string): { repo: string; rev: string; path: stri
1111
path: url.hash.slice(1),
1212
}
1313
}
14-
throw new Error(`unrecognized URI: ${JSON.stringify(uri)} (supported URI schemes: git)`)
14+
return null
1515
}

0 commit comments

Comments
 (0)