Illuminate\Routing\UrlGenerator::isValidUrl PHP Method

isValidUrl() public method

Determine if the given path is a valid URL.
public isValidUrl ( string $path ) : boolean
$path string
return boolean
    public function isValidUrl($path)
    {
        if (Str::startsWith($path, ['#', '//', 'mailto:', 'tel:', 'http://', 'https://'])) {
            return true;
        }
        return filter_var($path, FILTER_VALIDATE_URL) !== false;
    }

Usage Example

Beispiel #1
0
 /**
  * Do a few checks to get the theme path for a given asset url.
  *
  * @param string $url
  * @return string
  */
 protected function assetUrl($url)
 {
     if ($this->url->isValidUrl($url)) {
         return $url;
     }
     $theme = StylistFacade::current();
     if ($theme) {
         $themePath = $theme->getAssetPath();
         $url = "themes/{$themePath}/{$url}";
     }
     return $url;
 }
All Usage Examples Of Illuminate\Routing\UrlGenerator::isValidUrl