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) {
157157 const blobIndex = splits . indexOf ( "blob" , 2 ) ;
158158 const treeIndex = splits . indexOf ( "tree" , 2 ) ;
159159 const commitIndex = splits . indexOf ( "commit" , 2 ) ;
160+ const issuesIndex = splits . indexOf ( "issues" , 2 ) ;
160161 const srcIndex = splits . indexOf ( "src" , 2 ) ;
161162 const rawIndex = splits . indexOf ( "raw" , 2 ) ;
162163 const editIndex = splits . indexOf ( "edit" , 2 ) ;
163164 nameIndex = dashIndex > 0 ? dashIndex - 1
164165 : blobIndex > 0 ? blobIndex - 1
166+ : issuesIndex > 0 ? issuesIndex - 1
165167 : treeIndex > 0 ? treeIndex - 1
166168 : commitIndex > 0 ? commitIndex - 1
167169 : srcIndex > 0 ? srcIndex - 1
@@ -171,7 +173,7 @@ function gitUrlParse(url) {
171173
172174 urlInfo . owner = splits . slice ( 0 , nameIndex ) . join ( '/' ) ;
173175 urlInfo . name = splits [ nameIndex ] ;
174- if ( commitIndex ) {
176+ if ( commitIndex && issuesIndex < 0 ) {
175177 urlInfo . commit = splits [ nameIndex + 2 ]
176178 }
177179 }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const URLS = {
1313 , ref : "https://github.com/42IonicaBizau/git-url-parse/blob/master/test/index.js"
1414 , shorthand : "42IonicaBizau/git-url-parse"
1515 , commit : "https://github.com/42IonicaBizau/git-url-parse/commit/9c6443245ace92d237b7b274d4606a616e071c4e"
16+ , issue : "https://github.com/IonicaBizau/git-url-parse/issues/133"
1617} ;
1718
1819const gitUser = ( url ) => url . replace ( 'custom-user@' , 'git@' ) ;
@@ -514,4 +515,10 @@ tester.describe("parse urls", test => {
514515 test . expect ( res . name ) . toBe ( "git-url-parse" ) ;
515516 test . expect ( res . commit ) . toBe ( "9c6443245ace92d237b7b274d4606a616e071c4e" ) ;
516517 } ) ;
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+ } ) ;
517524} ) ;
You can’t perform that action at this time.
0 commit comments