Skip to content

Commit

Permalink
fix: Incorrect parsing of URLs
Browse files Browse the repository at this point in the history
Incorrect parsing of URLs like [email protected]:owner/libraries/my-library.git
  • Loading branch information
aatumaykin authored and marcocesarato committed Mar 12, 2021
1 parent c5c4e66 commit 24ca1c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Git/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public static function parseRemoteUrl()
'#^(?P<protocol>https?|git|ssh|rsync)\://(?:(?P<user>.+)@)*(?P<host>[a-z0-9_.-]*)[:/]*(?P<port>[\d]+){0,1}(?P<pathname>\/((?P<owner>[\w\-]+)\/)?((?P<repository>[\w\-\.]+?)(\.git|\/)?)?)$#smi',
'#(git\+)?((?P<protocol>\w+)://)((?P<user>\w+)@)?((?P<host>[\w\.\-]+))(:(?P<port>\d+))?(?P<pathname>(\/(?P<owner>\w+)/)?(\/?(?P<repository>[\w\-]+)(\.git|\/)?)?)$#smi',
'#^(?:(?P<user>.+)@)*(?P<host>[a-z0-9_.-]*)[:]*(?P<port>[\d]+){0,1}(?P<pathname>\/?(?P<owner>.+)/(?P<repository>.+).git)$#smi',
'#((?P<user>\w+)@)?((?P<host>[\w\.\-]+))[\:\/]{1,2}(?P<pathname>((?P<owner>\w+)/)?((?P<repository>[\w\-]+)(\.git|\/)?)?)$#smi',
'#((?P<user>\w+)@)?((?P<host>[\w\.\-]+))[\:\/]{1,2}(?P<pathname>((?P<owner>\w+)/)?((?P<repository>[\w\-/]+)(\.git|\/)?)?)$#smi',
];
foreach ($patterns as $pattern) {
if (preg_match($pattern, $url, $match)) {
Expand Down

0 comments on commit 24ca1c2

Please sign in to comment.