Mecha CMS

Extract current URL data.

URL::short()

Convert full URL into relative URL.

2.0.02.2.0static
URL::short(string $path, $root = true);

Example:

$A = URL::short('http://mecha-cms.com');
$B = URL::short('http://mecha-cms.com/foo');
$C = URL::short('http://mecha-cms.com?foo');
$D = URL::short('http://mecha-cms.com&foo');
$E = URL::short('http://mecha-cms.com#foo');
$F = URL::short('http://mecha-cms.com/foo/bar');
$G = URL::short('http://mecha-cms.com?foo&bar');
$H = URL::short('http://mecha-cms.com&foo&bar');
$I = URL::short('//mecha-cms.com');
$J = URL::short('http://example.com'); // External URL
$K = URL::short('//example.com'); // External URL with relative protocol

Result:

$A = '';
$B = '/foo';
$C = '?foo';
$D = '&foo';
$E = '#foo';
$F = '/foo/bar';
$G = '?foo&bar';
$H = '&foo&bar';
$I = '';
$J = 'http://example.com';
$K = '//example.com';

Note: If $root is false, then the sub-directory path where the CMS is being installed will be removed too, and the leading / will also be removed. The $root parameter changes makes sense only when Mecha is installed in a sub-directory.