private function derivePath() { if ($this->absoluteUrl->hasPath() && $this->absoluteUrl->getPath()->isRelative()) { if ($this->sourceUrl->hasPath()) { /* @var $pathDirectory \webignition\NormalisedUrl\Path\Path */ $rawPathDirectory = $this->sourceUrl->getPath()->hasFilename() ? dirname($this->sourceUrl->getPath()) : (string) $this->sourceUrl->getPath(); $pathDirectory = new \webignition\NormalisedUrl\Path\Path($rawPathDirectory); $derivedPath = $pathDirectory; if (!$pathDirectory->hasTrailingSlash()) { $derivedPath .= '/'; } $derivedPath .= $this->absoluteUrl->getPath(); $normalisedDerivedPath = new \webignition\NormalisedUrl\Path\Path((string) $derivedPath); $this->absoluteUrl->setPath($normalisedDerivedPath); } } if (!$this->absoluteUrl->hasPath()) { if ($this->sourceUrl->hasPath()) { $this->absoluteUrl->setPath($this->sourceUrl->getPath()); } } }
/** * 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; }