UrlHelper
in package
FinalYes
URL Utility.
Table of Contents
Methods
- domain() : string
- Extract only the protocol and origin from the URL.
- withoutFile() : string
- Remove the filename portion from the URL.
Methods
domain()
Extract only the protocol and origin from the URL.
public
static domain(string $url) : string
use \X\Util\UrlHelper;
UrlHelper::domain('https://abc.com');// "https://abc.com"
UrlHelper::domain('https://abc.com?name=foo');// "https://abc.com"
UrlHelper::domain('https://abc.com/index.html');// "https://abc.com"
UrlHelper::domain('https://abc.com/index.html?name=foo');// "https://abc.com"
UrlHelper::domain('https://abc.com/def/index.html');// "https://abc.com"
UrlHelper::domain('https://abc.com/def/index.html?name=foo');// "http://abc.com"
UrlHelper::domain('//abc.com');// "//abc.com"
UrlHelper::domain('//abc.com/');// "//abc.com"
UrlHelper::domain('//abc.com/index.html');// "//abc.com"
UrlHelper::domain('//abc.com/def/index.html');// "//abc.com"
UrlHelper::domain('//abc.com?name=foo');// "//abc.com"
UrlHelper::domain('//abc.com/?name=foo');// "//abc.com"
UrlHelper::domain('//abc.com/index.html?name=foo');// "//abc.com"
UrlHelper::domain('//abc.com/def/index.html?name=foo');// "//abc.com"
Parameters
- $url : string
-
URL.
Return values
string —Protocol and origin taken from the URL.
withoutFile()
Remove the filename portion from the URL.
public
static withoutFile(string $url) : string
use \X\Util\UrlHelper;
UrlHelper::withoutFile('https://abc.com');// => "https://abc.com"
UrlHelper::withoutFile('https://abc.com?name=foo');// => "https://abc.com"
UrlHelper::withoutFile('https://abc.com/index.html');// => "https://abc.com"
UrlHelper::withoutFile('https://abc.com/index.html?name=foo');// => "https://abc.com"
UrlHelper::withoutFile('https://abc.com/def/index.html');// => "https://abc.com/abc"
UrlHelper::withoutFile('https://abc.com/def/index.html?name=foo');// => "http://abc.com/abc"
UrlHelper::withoutFile('//abc.com');// => "//abc.com"
UrlHelper::withoutFile('//abc.com/');// => "//abc.com"
UrlHelper::withoutFile('//abc.com/index.html');// => "//abc.com"
UrlHelper::withoutFile('//abc.com/def/index.html');// => "//abc.com/abc"
UrlHelper::withoutFile('//abc.com?name=foo');// => "//abc.com"
UrlHelper::withoutFile('//abc.com/?name=foo');// => "//abc.com"
UrlHelper::withoutFile('//abc.com/index.html?name=foo');// => "//abc.com"
UrlHelper::withoutFile('//abc.com/def/index.html?name=foo');// => "//abc.com/abc"
Parameters
- $url : string
-
URL.
Return values
string —URL with filenames stripped.