public function testToStringWithConvertIdnToUtf8Enabled() { $source = 'http://artesan.xn--a-iga.com/'; $expectedUrl = 'http://artesan.ía.com/'; $url = new NormalisedUrl($source); $url->getConfiguration()->enableConvertIdnToUtf8(); $this->assertEquals($expectedUrl, (string) $url); }
public function matches($content = null) { if (trim($content) == '') { return false; } if ($content != strip_tags($content)) { return false; } $contentLines = explode("\n", $content); foreach ($contentLines as $contentLine) { $url = new NormalisedUrl($contentLine); if (!$url->hasScheme()) { return false; } } return true; }
private function derivePass() { if (!$this->absoluteUrl->hasPass() && $this->sourceUrl->hasPass()) { $this->absoluteUrl->setPass($this->sourceUrl->getPass()); } }
/** * * @param array $refDomains * @return array */ private function getExpectedErrorValuesByRefDomain($refDomains = array()) { $expectedErrorValues = array(); foreach ($this->expectedErrorValues as $errorValueSet) { $errorValueSetRefUrl = new NormalisedUrl($errorValueSet['ref']); if (in_array((string) $errorValueSetRefUrl->getHost(), $refDomains)) { $expectedErrorValues[] = $errorValueSet; } } return $expectedErrorValues; }
/** * * @param NormalisedUrl $url * @return boolean */ private function isUrlDomainToBeIncluded(NormalisedUrl $url) { return !in_array($url->getHost(), $this->getConfiguration()->getDomainsToExclude()); }
/** * Get the URL where we expect to find the robots.txt file * * @return string */ public function getExpectedRobotsTxtFileUrl() { if ($this->getConfiguration()->getRootUrl()->getRoot() == '') { return (string) $this->rootUrl . self::DEFAULT_SITEMAP_TXT_FILE_NAME; } $rootUrl = new NormalisedUrl($this->getConfiguration()->getRootUrl()->getRoot()); $rootUrl->setPath('/' . self::ROBOTS_TXT_FILE_NAME); return (string) $rootUrl; }