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 {
17
17
return
18
18
}
19
19
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 )
26
21
27
22
const threads = await fetchDiscussionThreads ( {
28
23
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 ,
32
27
} )
33
28
34
29
const decorations : sourcegraph . TextDocumentDecoration [ ] = [ ]
@@ -42,7 +37,7 @@ export function activate(): void {
42
37
return
43
38
}
44
39
const target : SourcegraphGQL . IDiscussionThreadTargetRepo = thread . target
45
- if ( target . relativePath !== uri . filePath ) {
40
+ if ( target . relativePath !== uri . path ) {
46
41
// TODO(slimsag): shouldn't the discussions API return threads created in different files and moved here, too? lol :facepalm:
47
42
return // comment has since moved to a different file.
48
43
}
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