protected $cache = [];
/**
- * Map of repo URLs to viewer URLs. Access via static method getViewers().
+ * @var array|false Map of repo URLs to viewer URLs. Access via static method getViewers().
*/
private static $viewers = false;
if ( $url === false ) {
return false;
}
- if ( substr( $url, -4 ) !== '.git' ) {
- $url .= '.git';
- }
foreach ( self::getViewers() as $repo => $viewer ) {
$pattern = '#^' . $repo . '$#';
if ( preg_match( $pattern, $url, $matches ) ) {
'%h' => substr( $headSHA1, 0, 7 ),
'%H' => $headSHA1,
'%r' => urlencode( $matches[1] ),
+ '%R' => $matches[1],
];
return strtr( $viewerUrl, $replacements );
}