File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ beforeAll(async () => {
7575 shell : true ,
7676 } ,
7777 ) ;
78- } , 70_000 ) ;
78+ } , 180_000 ) ;
7979
8080afterAll ( async ( ) => {
8181 await server . ensureClose ( ) ;
@@ -156,7 +156,7 @@ describe.sequential.each([
156156 expect ( process . stderr ) . toContain (
157157 "private-playground/ because the package is private" ,
158158 ) ;
159- } , 20_000 ) ;
159+ } , 60_000 ) ;
160160
161161 it ( `serves and installs playground-a for ${ mode } ` , async ( ) => {
162162 const [ owner , repo ] = payload . repository . full_name . split ( "/" ) ;
Original file line number Diff line number Diff line change @@ -47,6 +47,24 @@ describe("utils", () => {
4747 utils . extractOwnerAndRepo ( "git+http://github.com/org/repo.git" ) ,
4848 ) . toEqual ( [ "org" , "repo" ] ) ;
4949 } ) ;
50+
51+ it ( "returns org and repo for GitHub shorthand" , ( ) => {
52+ expect ( utils . extractOwnerAndRepo ( "org/repo" ) ) . toEqual ( [ "org" , "repo" ] ) ;
53+ } ) ;
54+
55+ it ( "returns org and repo for github: shorthand" , ( ) => {
56+ expect ( utils . extractOwnerAndRepo ( "github:org/repo" ) ) . toEqual ( [
57+ "org" ,
58+ "repo" ,
59+ ] ) ;
60+ } ) ;
61+
62+ it ( "returns org and repo for URLs without .git suffix" , ( ) => {
63+ expect ( utils . extractOwnerAndRepo ( "https://github.com/org/repo" ) ) . toEqual ( [
64+ "org" ,
65+ "repo" ,
66+ ] ) ;
67+ } ) ;
5068 } ) ;
5169
5270 describe ( "extractRepository" , ( ) => {
Original file line number Diff line number Diff line change 11import type { PackageManifest } from "query-registry" ;
22
33const githubUrlRegex =
4- / ^ (?: g i t \+ ) ? h t t p s ? : \/ \/ g i t h u b \. c o m \/ ( [ ^ / ] + ) \/ ( [ ^ / ] + ) \. g i t $ / ;
4+ / ^ (?: g i t \+ ) ? h t t p s ? : \/ \/ g i t h u b \. c o m \/ ( [ ^ / ] + ) \/ ( [ ^ / ] + ) \/ ? $ / ;
5+ const githubShorthandRegex = / ^ (?: g i t h u b : ) ? ( [ ^ / ] + ) \/ ( [ ^ / ] + ) $ / ;
56
67export function extractOwnerAndRepo (
78 repositoryUrl : string ,
89) : [ string , string ] | null {
9- const match = repositoryUrl . match ( githubUrlRegex ) ;
10+ const match =
11+ repositoryUrl . match ( githubUrlRegex ) ??
12+ repositoryUrl . match ( githubShorthandRegex ) ;
1013
1114 if ( match ) {
12- return [ match [ 1 ] , match [ 2 ] ] ;
15+ let repo = match [ 2 ] ;
16+ if ( repo . endsWith ( ".git" ) ) {
17+ repo = repo . slice ( 0 , - 4 ) ;
18+ } else if ( repo . includes ( ".git" ) ) {
19+ return null ;
20+ }
21+
22+ return [ match [ 1 ] , repo ] ;
1323 }
1424
1525 return null ;
You can’t perform that action at this time.
0 commit comments