File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,7 @@ function gitUrlParse(url) {
162162 const rawIndex = splits . indexOf ( "raw" , 2 ) ;
163163 const editIndex = splits . indexOf ( "edit" , 2 ) ;
164164 nameIndex = dashIndex > 0 ? dashIndex - 1
165+ : blobIndex > 0 && treeIndex > 0 ? Math . min ( blobIndex - 1 , treeIndex - 1 )
165166 : blobIndex > 0 ? blobIndex - 1
166167 : issuesIndex > 0 ? issuesIndex - 1
167168 : treeIndex > 0 ? treeIndex - 1
Original file line number Diff line number Diff line change @@ -521,4 +521,15 @@ tester.describe("parse urls", test => {
521521 test . expect ( res . name ) . toBe ( "git-url-parse" ) ;
522522 test . expect ( res . organization ) . toBe ( "IonicaBizau" ) ;
523523 } ) ;
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+ } ) ;
524535} ) ;
You can’t perform that action at this time.
0 commit comments