public static function parse($from_url)
{
$base_url = Site::get_path('base', true);
/*
* Strip out the base URL from the requested URL
* but only if the base URL isn't /
*/
if (strpos($from_url, $base_url) === 0) {
$from_url = MultiByte::substr($from_url, MultiByte::strlen($base_url));
}
/* Trim off any leading or trailing slashes */
$from_url = trim($from_url, '/');
/* Remove the querystring from the URL */
if (MultiByte::strpos($from_url, '?') !== false) {
list($from_url, ) = explode('?', $from_url);
}
$url = URL::instance();
$url->load_rules();
// Cached in singleton
/*
* Run the stub through the regex matcher
*/
self::$stub = $from_url;
/** @var RewriteRule $rule */
foreach ($url->rules as $rule) {
if ($rule->match($from_url)) {
$url->matched_rule = $rule;
/* Stop processing at first matched rule... */
return $rule;
}
}
return false;
}