From 9572a6bea7eed41d11634f735cb6b7ad14391690 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sun, 3 Dec 2023 12:49:08 +1100 Subject: [PATCH] Make toRelative check the config internally --- src/Html/UrlServiceProvider.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Html/UrlServiceProvider.php b/src/Html/UrlServiceProvider.php index 0b8f45dfe..773ebd08f 100644 --- a/src/Html/UrlServiceProvider.php +++ b/src/Html/UrlServiceProvider.php @@ -1,6 +1,7 @@ app['url']; $provider->macro('toRelative', function($url) use ($provider) { - $fullUrl = $provider->to($url); - return parse_url($fullUrl, PHP_URL_PATH) - . (($query = parse_url($fullUrl, PHP_URL_QUERY)) ? '?' . $query : '') - . (($fragment = parse_url($fullUrl, PHP_URL_FRAGMENT)) ? '#' . $fragment : ''); + if (Config::get('system.relative_links', false)) { + $fullUrl = $provider->to($url); + return parse_url($fullUrl, PHP_URL_PATH) + . (($query = parse_url($fullUrl, PHP_URL_QUERY)) ? '?' . $query : '') + . (($fragment = parse_url($fullUrl, PHP_URL_FRAGMENT)) ? '#' . $fragment : ''); + } + + return $provider->to($url); }); }