$_SERVER['SCRIPT_NAME'] = '/hordeurl/test.php';
$this->assertEquals('/hordeurl/', (string)Horde::selfUrl());
$this->assertEquals('/hordeurl/foo/bar?foo=bar&x=y', (string)Horde::selfUrl(true));
+
+ // Special cases.
+ $_SERVER['REQUEST_URI'] = '/test/42?id=42';
+ $_SERVER['SCRIPT_NAME'] = '/test/index.php';
+ $_SERVER['QUERY_STRING'] = 'id=42&id=42';
+ $this->assertEquals('/test/42?id=42', (string)Horde::selfUrl(true));
}
}
}
$search = array($search);
if (!empty($_SERVER['QUERY_STRING'])) {
- $search[] = '?' . $_SERVER['QUERY_STRING'];
+ // We can't use QUERY_STRING directly because URL rewriting
+ // might add more parameters to the query string than those
+ // from the request URI.
+ $url = parse_url($_SERVER['REQUEST_URI']);
+ if (!empty($url['query'])) {
+ $search[] = '?' . $url['query'];
+ }
}
$path = str_replace($search, '', $_SERVER['REQUEST_URI']);
if ($path == '/') {
$_SERVER['REQUEST_URI'] = '/horde/index.php/foo/bar?baz';
$_SERVER['QUERY_STRING'] = 'baz';
$this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
+
+ $_SERVER['REQUEST_URI'] = '/test/42?id=42';
+ $_SERVER['SCRIPT_NAME'] = '/test/index.php';
+ $_SERVER['QUERY_STRING'] = 'id=42&id=42';
+ $this->assertEquals('/42', Horde_Util::getPathInfo());
}
}