From 1edb7b6126b3f4afa5947c647e9099e24a985442 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 7 Feb 2024 23:22:24 +0000 Subject: [PATCH] more tests --- core/tests/UtilTest.php | 16 ++++++++++------ core/util.php | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/tests/UtilTest.php b/core/tests/UtilTest.php index bca8c98f..7fa13806 100644 --- a/core/tests/UtilTest.php +++ b/core/tests/UtilTest.php @@ -165,20 +165,24 @@ class UtilTest extends TestCase public function test_get_query(): void { - // no query string - $_SERVER["REQUEST_URI"] = "/tasty/cake"; + // niceurls + $_SERVER["REQUEST_URI"] = "/test/tasty/cake"; $this->assertEquals("/tasty/cake", _get_query()); - // query string - $_SERVER["REQUEST_URI"] = "index.php?q=/tasty/cake"; + // no niceurls + $_SERVER["REQUEST_URI"] = "/test/index.php?q=/tasty/cake"; $this->assertEquals("/tasty/cake", _get_query()); // leave url encoding alone - $_SERVER["REQUEST_URI"] = "index.php?q=/tasty/cake%20pie"; + $_SERVER["REQUEST_URI"] = "/test/index.php?q=/tasty/cake%20pie"; $this->assertEquals("/tasty/cake%20pie", _get_query()); // if just viewing index.php - $_SERVER["REQUEST_URI"] = "index.php"; + $_SERVER["REQUEST_URI"] = "/test/index.php"; + $this->assertEquals("/", _get_query()); + + // niceurl root + $_SERVER["REQUEST_URI"] = "/test/"; $this->assertEquals("/", _get_query()); } } diff --git a/core/util.php b/core/util.php index 2868b587..cbdaead7 100644 --- a/core/util.php +++ b/core/util.php @@ -740,8 +740,8 @@ function _get_query(): string return "/"; } - // otherwise, use the request URI - return $parts["path"]; + // otherwise, use the request URI minus the base path + return substr($parts["path"], strlen(get_base_href())); }