Skip to content

Commit f8c7148

Browse files
authored
ignore unrecognized URIs (#15)
ignore unrecognized URIs
2 parents 18c9a14 + ad87153 commit f8c7148

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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,

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)