Skip to content

Commit

Permalink
Fix for issue #16. Parsing urls that are only a fragment.
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed Feb 20, 2017
1 parent a0ccf56 commit dd4fe3a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
14 changes: 14 additions & 0 deletions tests/ParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]

]

];

Expand Down
8 changes: 7 additions & 1 deletion tests/ResolveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],

];

Expand Down

0 comments on commit dd4fe3a

Please sign in to comment.