Skip to content

Commit 4a286c9

Browse files
Avoid call on null
1 parent 4c633fa commit 4a286c9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Tests/UriResolverTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public static function provideResolverTests()
8181
['/foo', 'file:///bar/baz', 'file:///foo'],
8282
['foo', 'file:///', 'file:///foo'],
8383
['foo', 'file:///bar/baz', 'file:///bar/foo'],
84+
85+
['foo', 'http://localhost?bar=1', 'http://localhost/foo'],
86+
['foo', 'http://localhost#bar', 'http://localhost/foo'],
8487
];
8588
}
8689
}

UriResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function resolve(string $uri, ?string $baseUri): string
7070
}
7171

7272
// relative path
73-
$path = parse_url(substr($baseUri, \strlen($baseUriCleaned)), \PHP_URL_PATH);
73+
$path = parse_url(substr($baseUri, \strlen($baseUriCleaned)), \PHP_URL_PATH) ?? '';
7474
$path = self::canonicalizePath(substr($path, 0, strrpos($path, '/')).'/'.$uri);
7575

7676
return $baseUriCleaned.('' === $path || '/' !== $path[0] ? '/' : '').$path;

0 commit comments

Comments
 (0)