Ejemplo n.º 1
0
 /**
  * @param string $prefix
  * @throws CM_Exception
  */
 public function popPathPrefix($prefix)
 {
     $path = new Stringy\Stringy($this->getPath());
     if (!$path->startsWith($prefix)) {
         throw new CM_Exception('Cannot pop request\'s path by prefix.', null, ['path' => $this->getPath(), 'prefix' => $prefix]);
     }
     $path = $path->removeLeft($prefix);
     $path = $path->ensureLeft('/');
     $this->setPath((string) $path);
 }
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']);
     });
 }