mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-08-06 06:07:29 +02:00
fix get_self_url() misbehaving in plugins/
This commit is contained in:
parent
d8718b7574
commit
42ebdb027e
@ -483,7 +483,7 @@ class Config {
|
||||
|
||||
$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("/(\/plugins(.local))\/.{1,}$/", "", $self_url_path);
|
||||
$self_url_path = preg_replace("/(\/plugins(.local)?)\/.{1,}$/", "", $self_url_path);
|
||||
|
||||
return rtrim($self_url_path, "/");
|
||||
}
|
||||
|
@ -128,6 +128,18 @@ final class SelfUrlPathTest extends TestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public function test_self_url_k(): void {
|
||||
$_SERVER = [];
|
||||
|
||||
$_SERVER["HTTP_HOST"] = "example.com";
|
||||
$_SERVER["REQUEST_URI"] = "/tt-rss/plugins/example/api/longpath/test.php/reader/api/0/stream/items/ids?n=1000&output=json&s=user/-/state/com.google/starred";
|
||||
|
||||
$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/
|
||||
|
Loading…
Reference in New Issue
Block a user