Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ComposerMirror.php

function ComposerMirror::processGitUrl

Parameters

non-empty-string $mirrorUrl:

Return value

string

2 calls to ComposerMirror::processGitUrl()
ComposerMirror::processHgUrl in vendor/composer/composer/src/Composer/Util/ComposerMirror.php
Package::getUrls in vendor/composer/composer/src/Composer/Package/Package.php
@phpstan-param list<array{url: non-empty-string, preferred: bool}>|null $mirrors

File

vendor/composer/composer/src/Composer/Util/ComposerMirror.php, line 52

Class

ComposerMirror
Composer mirror utilities

Namespace

Composer\Util

Code

public static function processGitUrl(string $mirrorUrl, string $packageName, string $url, ?string $type) : string {
    if (Preg::isMatch('#^(?:(?:https?|git)://github\\.com/|git@github\\.com:)([^/]+)/(.+?)(?:\\.git)?$#', $url, $match)) {
        $url = 'gh-' . $match[1] . '/' . $match[2];
    }
    elseif (Preg::isMatch('#^https://bitbucket\\.org/([^/]+)/(.+?)(?:\\.git)?/?$#', $url, $match)) {
        $url = 'bb-' . $match[1] . '/' . $match[2];
    }
    else {
        $url = Preg::replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
    }
    return str_replace([
        '%package%',
        '%normalizedUrl%',
        '%type%',
    ], [
        $packageName,
        $url,
        $type,
    ], $mirrorUrl);
}
RSS feed
Powered by Drupal