public function testAbsoluteUrlIsRecognisedAsNonRelative() { $url = new \webignition\Url\Url('http://example.com/absolute/url'); $this->assertFalse($url->isRelative()); }
/** * * @return string */ private function findSitemapUrlsFromRobotsTxt() { $robotsTxtParser = new \webignition\RobotsTxt\File\Parser(); $robotsTxtParser->setSource($this->getRobotsTxtContent()); $robotsTxtFile = $robotsTxtParser->getFile(); $urls = array(); if ($robotsTxtFile->directiveList()->containsField('sitemap')) { $sitemapDirectives = $robotsTxtFile->directiveList()->filter(array('field' => 'sitemap')); foreach ($sitemapDirectives->get() as $sitemapDirective) { /* @var $sitemapDirective \webignition\RobotsTxt\Directive\Directive */ $sitemapUrl = new \webignition\Url\Url((string) $sitemapDirective->getValue()); if ($sitemapUrl->isRelative()) { $absoluteUrlDeriver = new \webignition\AbsoluteUrlDeriver\AbsoluteUrlDeriver((string) $sitemapUrl, $this->getConfiguration()->getRootUrl()); $urls[] = (string) $absoluteUrlDeriver->getAbsoluteUrl(); } else { $urls[] = (string) $sitemapUrl; } } } return $urls; }