From 66c372ce285f827bed391cf19316d2a8362e93c2 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Mon, 15 Apr 2019 14:50:46 +1200 Subject: [PATCH] Include baseURL with relative setGetVar() links (#8834) * Return baseURL with setGetVar * Adjust testSetGetVar tests for base url --- src/Control/HTTP.php | 2 +- tests/php/Control/HTTPTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Control/HTTP.php b/src/Control/HTTP.php index b050e29e9..61c9bdabd 100644 --- a/src/Control/HTTP.php +++ b/src/Control/HTTP.php @@ -268,7 +268,7 @@ class HTTP $newUri = $scheme . '://' . $user . $host . $port . $path . $params . $fragment; if ($isRelative) { - return Director::makeRelative($newUri); + return Director::baseURL() . Director::makeRelative($newUri); } return $newUri; diff --git a/tests/php/Control/HTTPTest.php b/tests/php/Control/HTTPTest.php index c904937c1..9d52df2ac 100644 --- a/tests/php/Control/HTTPTest.php +++ b/tests/php/Control/HTTPTest.php @@ -246,13 +246,13 @@ class HTTPTest extends FunctionalTest }, 'relative/url/'); $this->assertEquals( - 'relative/url?foo=bar', + '/relative/url?foo=bar', HTTP::setGetVar('foo', 'bar', 'relative/url'), 'Relative URL without existing query params' ); $this->assertEquals( - 'relative/url?baz=buz&foo=bar', + '/relative/url?baz=buz&foo=bar', HTTP::setGetVar('foo', 'bar', '/relative/url?baz=buz'), 'Relative URL with existing query params, and new added key' );