File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -157,11 +157,13 @@ function gitUrlParse(url) {
157
157
const blobIndex = splits . indexOf ( "blob" , 2 ) ;
158
158
const treeIndex = splits . indexOf ( "tree" , 2 ) ;
159
159
const commitIndex = splits . indexOf ( "commit" , 2 ) ;
160
+ const issuesIndex = splits . indexOf ( "issues" , 2 ) ;
160
161
const srcIndex = splits . indexOf ( "src" , 2 ) ;
161
162
const rawIndex = splits . indexOf ( "raw" , 2 ) ;
162
163
const editIndex = splits . indexOf ( "edit" , 2 ) ;
163
164
nameIndex = dashIndex > 0 ? dashIndex - 1
164
165
: blobIndex > 0 ? blobIndex - 1
166
+ : issuesIndex > 0 ? issuesIndex - 1
165
167
: treeIndex > 0 ? treeIndex - 1
166
168
: commitIndex > 0 ? commitIndex - 1
167
169
: srcIndex > 0 ? srcIndex - 1
@@ -171,7 +173,7 @@ function gitUrlParse(url) {
171
173
172
174
urlInfo . owner = splits . slice ( 0 , nameIndex ) . join ( '/' ) ;
173
175
urlInfo . name = splits [ nameIndex ] ;
174
- if ( commitIndex ) {
176
+ if ( commitIndex && issuesIndex < 0 ) {
175
177
urlInfo . commit = splits [ nameIndex + 2 ]
176
178
}
177
179
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const URLS = {
13
13
, ref : "https://github.com/42IonicaBizau/git-url-parse/blob/master/test/index.js"
14
14
, shorthand : "42IonicaBizau/git-url-parse"
15
15
, commit : "https://github.com/42IonicaBizau/git-url-parse/commit/9c6443245ace92d237b7b274d4606a616e071c4e"
16
+ , issue : "https://github.com/IonicaBizau/git-url-parse/issues/133"
16
17
} ;
17
18
18
19
const gitUser = ( url ) => url . replace ( 'custom-user@' , 'git@' ) ;
@@ -514,4 +515,10 @@ tester.describe("parse urls", test => {
514
515
test . expect ( res . name ) . toBe ( "git-url-parse" ) ;
515
516
test . expect ( res . commit ) . toBe ( "9c6443245ace92d237b7b274d4606a616e071c4e" ) ;
516
517
} ) ;
518
+
519
+ test . should ( "parse issues urls" , ( ) => {
520
+ var res = gitUrlParse ( URLS . issue ) ;
521
+ test . expect ( res . name ) . toBe ( "git-url-parse" ) ;
522
+ test . expect ( res . organization ) . toBe ( "IonicaBizau" ) ;
523
+ } ) ;
517
524
} ) ;
You can’t perform that action at this time.
0 commit comments