Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export function activate(): void {
}

const uri = resolveURI(editor.document.uri)
if (!uri) {
return
}

const threads = await fetchDiscussionThreads({
first: 10000,
Expand Down
4 changes: 2 additions & 2 deletions src/uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Resolve a URI of the forms git://github.com/owner/repo?rev#path and file:///path to an absolute reference, using
* the given base (root) URI.
*/
export function resolveURI(uri: string): { repo: string; rev: string; path: string } {
export function resolveURI(uri: string): { repo: string; rev: string; path: string } | null {
const url = new URL(uri)
if (url.protocol === 'git:') {
return {
Expand All @@ -11,5 +11,5 @@ export function resolveURI(uri: string): { repo: string; rev: string; path: stri
path: url.hash.slice(1),
}
}
throw new Error(`unrecognized URI: ${JSON.stringify(uri)} (supported URI schemes: git)`)
return null
}