diff --git a/src/http_build_url.php b/src/http_build_url.php index 0dfdbba..14d8e49 100644 --- a/src/http_build_url.php +++ b/src/http_build_url.php @@ -93,7 +93,7 @@ function http_build_url($url, $parts = array(), $flags = HTTP_URL_REPLACE, &$new if (isset($parts['path']) && ($flags & HTTP_URL_JOIN_PATH)) { if (isset($url['path']) && substr($parts['path'], 0, 1) !== '/') { // Workaround for trailing slashes - $url['path'] .= 'a'; + $url['path'] .= "\0"; $url['path'] = rtrim( str_replace(basename($url['path']), '', $url['path']), '/' diff --git a/tests/HttpBuildUrlTest.php b/tests/HttpBuildUrlTest.php index 40a3f15..c32f129 100644 --- a/tests/HttpBuildUrlTest.php +++ b/tests/HttpBuildUrlTest.php @@ -170,7 +170,19 @@ public function testJoinPathTwo() $this->assertSame($expected, $actual); } - /** + public function testJoinPathThree() + { + $expected = "http://site.testing.com/apreview/testing/a/09-20a13/pa0a4/image/15.jpg"; + $actual = http_build_url( + "http://site.testing.com/apreview/testing/a/09-20a13/pa0a4/?code=asdfghjkl", + array('path' => 'image/15.jpg'), + HTTP_URL_JOIN_PATH | HTTP_URL_STRIP_FRAGMENT | HTTP_URL_STRIP_QUERY + ); + + $this->assertSame($expected, $actual); + } + + /** * @dataProvider bitmaskProvider */ public function testBitmasks($constant, $expected)