Skip to content

Commit

Permalink
Allow to use 0 in path
Browse files Browse the repository at this point in the history
  • Loading branch information
fr05t1k committed Sep 4, 2019
1 parent 1381865 commit 8db0c82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function resolve(string $basePath, string $newPath): string
$newParts['host'] = $pick('host');
$newParts['port'] = $pick('port');

$path = '';
if ($delta['path']) {
$path = $base['path'] ?: '/';
if (is_string($delta['path']) and strlen($delta['path']) > 0) {
// If the path starts with a slash
if ('/' === $delta['path'][0]) {
$path = $delta['path'];
Expand All @@ -66,9 +66,8 @@ function resolve(string $basePath, string $newPath): string
}
$path .= '/'.$delta['path'];
}
} else {
$path = $base['path'] ?: '/';
}

// Removing .. and .
$pathParts = explode('/', $path);
$newPathParts = [];
Expand Down
6 changes: 6 additions & 0 deletions tests/ResolveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ public function resolveData()
'#',
'http://example.org/path.json',
],
// Allow to use 0 in path
[
'http://example.org/',
'0',
'http://example.org/0',
],
];
}
}

0 comments on commit 8db0c82

Please sign in to comment.