File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,7 @@ function gitUrlParse(url) {
162
162
const rawIndex = splits . indexOf ( "raw" , 2 ) ;
163
163
const editIndex = splits . indexOf ( "edit" , 2 ) ;
164
164
nameIndex = dashIndex > 0 ? dashIndex - 1
165
+ : blobIndex > 0 && treeIndex > 0 ? Math . min ( blobIndex - 1 , treeIndex - 1 )
165
166
: blobIndex > 0 ? blobIndex - 1
166
167
: issuesIndex > 0 ? issuesIndex - 1
167
168
: treeIndex > 0 ? treeIndex - 1
Original file line number Diff line number Diff line change @@ -521,4 +521,15 @@ tester.describe("parse urls", test => {
521
521
test . expect ( res . name ) . toBe ( "git-url-parse" ) ;
522
522
test . expect ( res . organization ) . toBe ( "IonicaBizau" ) ;
523
523
} ) ;
524
+
525
+ // blob in repo path: https://github.com/IonicaBizau/git-url-parse/issues/167
526
+ test . should ( "handle 'blob' in repo path" , ( ) => {
527
+ var res = gitUrlParse ( "https://github.com/owner/id/tree/main/pkg/blob/data.yaml" ) ;
528
+ test . expect ( res . source ) . toBe ( "github.com" ) ;
529
+ test . expect ( res . owner ) . toBe ( "owner" ) ;
530
+ test . expect ( res . name ) . toBe ( "id" ) ;
531
+ test . expect ( res . pathname ) . toBe ( "/owner/id/tree/main/pkg/blob/data.yaml" ) ;
532
+ test . expect ( res . filepath ) . toBe ( "pkg/blob/data.yaml" ) ;
533
+ test . expect ( res . toString ( ) ) . toBe ( "https://github.com/owner/id" ) ;
534
+ } ) ;
524
535
} ) ;
You can’t perform that action at this time.
0 commit comments