@@ -213,10 +213,10 @@ function makeCompareUrl($pkg, $diff) {
213213}
214214
215215function getSourceRepoType ($ url ) {
216- if (preg_match ('/^git@bitbucket.org:(.*) \.git$/ ' , $ url )) {
216+ if (preg_match ('/^git@bitbucket\..+:.+ \.git$/ ' , $ url )) {
217217 return 'bitbucket ' ;
218218 }
219- if (preg_match ('/^git@github.com:(.*) \.git$/ ' , $ url )) {
219+ if (preg_match ('/^git@github\..+:.+ \.git$/ ' , $ url )) {
220220 return 'github ' ;
221221 }
222222 if (preg_match ('/^git@gitlab\..+:.+\.git$/ ' , $ url )) {
@@ -245,12 +245,18 @@ function formatCompareUnknown($url, $from, $to) {
245245}
246246
247247function formatCompareGithub ($ url , $ from , $ to ) {
248- $ url = preg_replace (['/\.git$/ ' , '/^git@github.com:/ ' ], ['' , 'https://github.com/ ' ], $ url );
248+ if (strpos ($ url , 'http ' ) === false ) {
249+ $ url = preg_replace ('/^git@(github\.[^:]+):/ ' , 'https://$1/ ' , $ url );
250+ }
251+ $ url = preg_replace ('/\.git$/ ' , '' , $ url );
249252 return sprintf ('%s/compare/%s...%s ' , $ url , urlencode ($ from ), urlencode ($ to ));
250253}
251254
252255function formatCompareBitbucket ($ url , $ from , $ to ) {
253- $ url = preg_replace (['/\.git$/ ' , '/^git@bitbucket.org:/ ' ], ['' , 'https://bitbucket.org/ ' ], $ url );
256+ if (strpos ($ url , 'http ' ) === false ) {
257+ $ url = preg_replace ('/^git@(bitbucket\.[^:]+):/ ' , 'https://$1/ ' , $ url );
258+ }
259+ $ url = preg_replace ('/\.git$/ ' , '' , $ url );
254260 return sprintf ('%s/branches/compare/%s%%0D%s ' , $ url , urlencode ($ to ), urlencode ($ from ));
255261}
256262
0 commit comments