Пример #1
0
 /**
  * Filter the URL by normalizing it and applying a default scheme if set
  *
  * @param  string $value
  * @return string
  */
 public function filter($value)
 {
     $defaultScheme = $this->defaultScheme ?: $this->enforcedScheme;
     // Reset default scheme if it is not a known scheme
     if (!UriFactory::getRegisteredSchemeClass($defaultScheme)) {
         $defaultScheme = null;
     }
     try {
         $uri = UriFactory::factory($value, $defaultScheme);
         if ($this->enforcedScheme && !$uri->getScheme()) {
             $this->enforceScheme($uri);
         }
     } catch (UriException $ex) {
         // We are unable to parse / enfore scheme with the given config and input
         return $value;
     }
     $uri->normalize();
     if (!$uri->isValid()) {
         return $value;
     }
     return $uri->toString();
 }