Ejemplo n.º 1
0
 public function testGetPathEmpty()
 {
     $urlParser = new CM_Http_UrlParser('http://www.example.com');
     $this->assertSame('/', $urlParser->getPath());
 }
Ejemplo n.º 2
0
 /**
  * @param string $host
  * @param string $path
  * @return bool
  * @throws CM_Exception
  */
 public function isUrlMatch($host, $path)
 {
     $matchList = [['host' => $this->getHost(), 'path' => $this->getPath()], ['host' => preg_replace('/^www\\./', '', $this->getHost()), 'path' => $this->getPath()]];
     if ($this->getUrlCdn()) {
         $urlCdn = new CM_Http_UrlParser($this->getUrlCdn());
         $matchList[] = ['host' => $urlCdn->getHost(), 'path' => $urlCdn->getPath()];
     }
     $path = new Stringy\Stringy($path);
     return Functional\some($matchList, function ($match) use($host, $path) {
         return $host === $match['host'] && $path->startsWith($match['path']);
     });
 }
Ejemplo n.º 3
0
 /**
  * @param string $url
  * @return bool
  */
 private function _isPageOnSameSite($url)
 {
     $urlParser = new CM_Http_UrlParser($url);
     if (!$this->_site->isUrlMatch($urlParser->getHost(), $urlParser->getPath())) {
         return false;
     }
     $request = $this->_createGetRequestWithUrl($url);
     $responseFactory = new CM_Http_ResponseFactory($this->getServiceManager());
     $response = $responseFactory->getResponse($request);
     return $response->getSite()->equals($this->getSite());
 }