diff --git a/lib/functions.php b/lib/functions.php index e89cd7b..45ee977 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -333,11 +333,11 @@ function($matches) { } // Taking off a fragment part - if (strpos($uri, '#')) { + if (strpos($uri, '#')!==false) { list($uri, $result['fragment']) = explode('#', $uri, 2); } // Taking off the query part - if (strpos($uri, '?')) { + if (strpos($uri, '?')!==false) { list($uri, $result['query']) = explode('?', $uri, 2); } diff --git a/tests/ParseTest.php b/tests/ParseTest.php index c26c57c..d9e2308 100644 --- a/tests/ParseTest.php +++ b/tests/ParseTest.php @@ -171,6 +171,20 @@ function parseData() { 'fragment' => null, ] ], + // Parial url + [ + '#foo', + [ + 'scheme' => null, + 'host' => null, + 'path' => null, + 'port' => null, + 'user' => null, + 'query' => null, + 'fragment' => 'foo', + ] + + ] ]; diff --git a/tests/ResolveTest.php b/tests/ResolveTest.php index 25de58e..f969975 100644 --- a/tests/ResolveTest.php +++ b/tests/ResolveTest.php @@ -80,7 +80,13 @@ function resolveData() { 'http://www.example.org', '#foo', 'http://www.example.org/#foo', - ] + ], + // Another fragment test + [ + 'http://example.org/path.json', + '#', + 'http://example.org/path.json', + ], ];