File tree Expand file tree Collapse file tree 2 files changed +20
-10
lines changed Expand file tree Collapse file tree 2 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -17,18 +17,13 @@ export function activate(): void {
1717 return
1818 }
1919
20- const u = new URL ( editor . document . uri )
21- const uri = {
22- repositoryName : u . pathname . slice ( 2 ) ,
23- revision : u . search . slice ( 1 ) ,
24- filePath : u . hash . slice ( 1 ) ,
25- }
20+ const uri = resolveURI ( editor . document . uri )
2621
2722 const threads = await fetchDiscussionThreads ( {
2823 first : 10000 ,
29- targetRepositoryName : uri . repositoryName ,
30- targetRepositoryPath : uri . filePath ,
31- relativeRev : uri . revision ,
24+ targetRepositoryName : uri . repo ,
25+ targetRepositoryPath : uri . path ,
26+ relativeRev : uri . rev ,
3227 } )
3328
3429 const decorations : sourcegraph . TextDocumentDecoration [ ] = [ ]
@@ -42,7 +37,7 @@ export function activate(): void {
4237 return
4338 }
4439 const target : SourcegraphGQL . IDiscussionThreadTargetRepo = thread . target
45- if ( target . relativePath !== uri . filePath ) {
40+ if ( target . relativePath !== uri . path ) {
4641 // TODO(slimsag): shouldn't the discussions API return threads created in different files and moved here, too? lol :facepalm:
4742 return // comment has since moved to a different file.
4843 }
Original file line number Diff line number Diff line change 1+ /**
2+ * Resolve a URI of the forms git://github.com/owner/repo?rev#path and file:///path to an absolute reference, using
3+ * the given base (root) URI.
4+ */
5+ export function resolveURI ( uri : string ) : { repo : string ; rev : string ; path : string } {
6+ const url = new URL ( uri )
7+ if ( url . protocol === 'git:' ) {
8+ return {
9+ repo : ( url . host + url . pathname ) . replace ( / ^ \/ * / , '' ) . toLowerCase ( ) ,
10+ rev : url . search . slice ( 1 ) . toLowerCase ( ) ,
11+ path : url . hash . slice ( 1 ) ,
12+ }
13+ }
14+ throw new Error ( `unrecognized URI: ${ JSON . stringify ( uri ) } (supported URI schemes: git)` )
15+ }
You can’t perform that action at this time.
0 commit comments