more tests

This commit is contained in:
Shish 2024-02-07 23:22:24 +00:00
parent e0d9a20f4c
commit 1edb7b6126
2 changed files with 12 additions and 8 deletions

View file

@ -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());
}
}

View file

@ -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()));
}