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

Breadcrumb

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

function ComposerRepository::canonicalizeUrl

Parameters

string $url:

Return value

non-empty-string

1 call to ComposerRepository::canonicalizeUrl()
ComposerRepository::loadRootServerFile in vendor/composer/composer/src/Composer/Repository/ComposerRepository.php

File

vendor/composer/composer/src/Composer/Repository/ComposerRepository.php, line 1304

Class

ComposerRepository
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Repository

Code

private function canonicalizeUrl(string $url) : string {
    if (strlen($url) === 0) {
        throw new \InvalidArgumentException('Expected a string with a value and not an empty string');
    }
    if (str_starts_with($url, '/')) {
        if (Preg::isMatch('{^[^:]++://[^/]*+}', $this->url, $matches)) {
            return $matches[0] . $url;
        }
        return $this->url;
    }
    return $url;
}
RSS feed
Powered by Drupal