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

Breadcrumb

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

function NoProxyPattern::match

Returns true if the url is matched by a rule

1 call to NoProxyPattern::match()
NoProxyPattern::test in vendor/composer/composer/src/Composer/Util/NoProxyPattern.php
Returns true if a URL matches the NO_PROXY pattern

File

vendor/composer/composer/src/Composer/Util/NoProxyPattern.php, line 106

Class

NoProxyPattern
Tests URLs against NO_PROXY patterns

Namespace

Composer\Util

Code

protected function match(int $index, string $hostName, stdClass $url) : bool {
    if (!($rule = $this->getRule($index, $hostName))) {
        // Data must have been misformatted
        return false;
    }
    if ($rule->ipdata) {
        // Match ipdata first
        if (!$url->ipdata) {
            return false;
        }
        if ($rule->ipdata->netmask) {
            return $this->matchRange($rule->ipdata, $url->ipdata);
        }
        $match = $rule->ipdata->ip === $url->ipdata->ip;
    }
    else {
        // Match host and port
        $haystack = substr($url->name, -strlen($rule->name));
        $match = stripos($haystack, $rule->name) === 0;
    }
    if ($match && $rule->port) {
        $match = $rule->port === $url->port;
    }
    return $match;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal