This repository was archived by the owner on Jul 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,11 @@ public static function fromString($endpoint)
4646 $ name = isset ($ map [0 ]) ? $ map [0 ] : $ endpoint ;
4747 $ version = isset ($ map [1 ]) ? $ map [1 ] : '* ' ;
4848
49+ // Convert user/package shorthand to GitHub url
50+ if (preg_match ('/^([-_a-z0-9]+)\/([-_a-z0-9]+)$/i ' , $ name )) {
51+ $ name = 'https://github.com/ ' . $ name . '.git ' ;
52+ }
53+
4954 return new self ($ name , $ version );
5055 }
5156}
Original file line number Diff line number Diff line change @@ -32,4 +32,24 @@ public function testReturnPackageAndVersionIsSet()
3232 $ this ->assertEquals ('jquery ' , $ packageNameVersion ->name );
3333 $ this ->assertEquals ('1.10.2 ' , $ packageNameVersion ->version );
3434 }
35+
36+ public function testReturnPackageGithubUrlFromShorthand ()
37+ {
38+ $ package = 'jquery/jquery ' ;
39+
40+ $ packageNameVersion = PackageNameVersionExtractor::fromString ($ package );
41+
42+ $ this ->assertEquals ('https://github.com/jquery/jquery.git ' , $ packageNameVersion ->name );
43+ $ this ->assertEquals ('* ' , $ packageNameVersion ->version );
44+ }
45+
46+ public function testReturnPackageGithubUrlAndVersionFromShorthand ()
47+ {
48+ $ package = 'jquery/jquery#1.10.2 ' ;
49+
50+ $ packageNameVersion = PackageNameVersionExtractor::fromString ($ package );
51+
52+ $ this ->assertEquals ('https://github.com/jquery/jquery.git ' , $ packageNameVersion ->name );
53+ $ this ->assertEquals ('1.10.2 ' , $ packageNameVersion ->version );
54+ }
3555}
You can’t perform that action at this time.
0 commit comments