- Deprecate Util\Network->isLocalLink to reduce dependency on DI class
$redirectTo = $this->__toString() . '/' . ltrim($toUrl, '/');
System::externalRedirect($redirectTo);
}
+
+ public function isLocalUrl(string $url): bool
+ {
+ return strpos(Strings::normaliseLink($url), Strings::normaliseLink((string)$this)) === 0;
+ }
+
+ public function isLocalUri(UriInterface $uri): bool
+ {
+ return $this->isLocalUrl((string)$uri);
+ }
}
* @param string $url
*
* @return bool
+ * @deprecated since 2023.09, please use BaseUrl->isLocalUrl or BaseUrl->isLocalUri instead.
*/
public static function isLocalLink(string $url): bool
{
- return (strpos(Strings::normaliseLink($url), Strings::normaliseLink(DI::baseUrl())) !== false);
+ return DI::baseUrl()->isLocalUrl($url);
}
/**