class Url (View source)

A collection of tools dealing with URLs.

Methods

static string
getPath(RequestInterface $request, string $home_url = '')

Get the path for the request relative to the home url.

static string
addLeadingSlash(string $url, boolean $leave_blank = false)

Ensure url has a leading slash

static string
removeLeadingSlash(string $url)

Ensure url does not have a leading slash

static string
addTrailingSlash(string $url, boolean $leave_blank = false)

Ensure url has a trailing slash

static string
removeTrailingSlash(string $url)

Ensure url does not have a trailing slash

Details

static string getPath(RequestInterface $request, string $home_url = '')

Get the path for the request relative to the home url.

Works only with absolute URLs.

Parameters

RequestInterface $request
string $home_url

Return Value

string

static string addLeadingSlash(string $url, boolean $leave_blank = false)

Ensure url has a leading slash

Parameters

string $url
boolean $leave_blank

Return Value

string

static string removeLeadingSlash(string $url)

Ensure url does not have a leading slash

Parameters

string $url

Return Value

string

static string addTrailingSlash(string $url, boolean $leave_blank = false)

Ensure url has a trailing slash

Parameters

string $url
boolean $leave_blank

Return Value

string

static string removeTrailingSlash(string $url)

Ensure url does not have a trailing slash

Parameters

string $url

Return Value

string