summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/Config.php8
-rw-r--r--tests/ConfigTest.php12
-rwxr-xr-xutils/phpunit.sh2
3 files changed, 15 insertions, 7 deletions
diff --git a/classes/Config.php b/classes/Config.php
index a1886e877..be9dd04e8 100644
--- a/classes/Config.php
+++ b/classes/Config.php
@@ -490,13 +490,9 @@ class Config {
$proto = self::is_server_https() ? 'https' : 'http';
$self_url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
- $self_url_path = preg_replace("/(\/api\/{1,})?(\w+\.php)?(\?.*$)?$/", "", $self_url_path);
+ $self_url_path = preg_replace("/(\/api\/{1,}|\/plugins(.local)?\/.{1,}\/{1,})?(\w+\.php)?(\?.*$)?$/", "", $self_url_path);
- if (substr($self_url_path, -1) === "/") {
- return substr($self_url_path, 0, -1);
- } else {
- return $self_url_path;
- }
+ return rtrim($self_url_path, "/");
}
}
/* sanity check stuff */
diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php
index 30f3a212a..f65f0060d 100644
--- a/tests/ConfigTest.php
+++ b/tests/ConfigTest.php
@@ -104,6 +104,18 @@ final class SelfUrlPathTest extends TestCase {
);
}
+ public function test_self_url_i(): void {
+ $_SERVER = [];
+
+ $_SERVER["HTTP_HOST"] = "example.com";
+ $_SERVER["REQUEST_URI"] = "/tt-rss////plugins.local/example///api/long path/test.php";
+
+ $this->assertEquals(
+ 'http://example.com/tt-rss',
+ Config::get_self_url(true)
+ );
+ }
+
public function test_get_self_dir(): void {
$this->assertEquals(
dirname(__DIR__), # we're in (app)/tests/
diff --git a/utils/phpunit.sh b/utils/phpunit.sh
index 8423798e4..e8f00d0f5 100755
--- a/utils/phpunit.sh
+++ b/utils/phpunit.sh
@@ -1,5 +1,5 @@
#!/bin/sh
docker run --rm -v $(pwd):/app \
- --workdir /app registry.fakecake.org/infra/php8.3-alpine:3.19 \
+ --workdir /app registry.fakecake.org/infra/php-fpm8.3-alpine3.19:latest \
php83 -d memory_limit=-1 ./vendor/bin/phpunit --exclude integration