pax_global_header00006660000000000000000000000064152521741250014516gustar00rootroot0000000000000052 comment=18627808c80621219f80337fa4adcee7a31aff7d http_build_url-1.0.2/000077500000000000000000000000001525217412500145365ustar00rootroot00000000000000http_build_url-1.0.2/.gitignore000066400000000000000000000000521525217412500165230ustar00rootroot00000000000000.DS_Store .idea build composer.lock vendorhttp_build_url-1.0.2/LICENSE000066400000000000000000000020701525217412500155420ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015 Jake A. Smith Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http_build_url-1.0.2/composer.json000066400000000000000000000011121525217412500172530ustar00rootroot00000000000000{ "name": "jakeasmith/http_build_url", "description": "Deprecated: use PHP 8.5's built-in Uri\\Rfc3986\\Uri instead. Provides http_build_url() for environments without pecl_http.", "license": "MIT", "abandoned": true, "authors": [ { "name": "Jake A. Smith", "email": "theman@jakeasmith.com", "homepage": "https://jakeasmith.com" } ], "support": { "issues": "https://github.com/jakeasmith/http_build_url/issues", "source": "https://github.com/jakeasmith/http_build_url" }, "autoload": { "files": ["src/http_build_url.php"] } } http_build_url-1.0.2/phpunit.xml.dist000066400000000000000000000013451525217412500177140ustar00rootroot00000000000000 ./tests ./src http_build_url-1.0.2/readme.md000066400000000000000000000025301525217412500163150ustar00rootroot00000000000000# http_build_url() for PHP **This package is deprecated and no longer maintained. Please move off it.** I wrote this in 2014 to provide `http_build_url()` without the pecl_http extension. PHP 8.5 now ships a built-in URI API that does the same job, so there's no reason to keep depending on this. Known bugs in this package, like joining a path onto a URL with a trailing slash stripping every "a" from it ([#25](https://github.com/jakeasmith/http_build_url/issues/25)), won't be fixed. ## Replacing it on PHP 8.5+ ```php use Uri\Rfc3986\Uri; // Replace parts of a URL echo Uri::parse('https://example.com/search?q=php#top') ->withPath('/docs') ->withQuery('page=2') ->withFragment(null) ->toString(); // https://example.com/docs?page=2 // Join a relative path and merge query strings // (was HTTP_URL_JOIN_PATH | HTTP_URL_JOIN_QUERY) $base = Uri::parse('https://example.com/v1/users?page=2'); parse_str($base->getQuery() ?? '', $query); echo $base->resolve('me') ->withQuery(http_build_query($query + ['fields' => 'name'])) ->toString(); // https://example.com/v1/me?page=2&fields=name ``` On older PHP, combine `parse_url()` and `http_build_query()`, or use a URI library such as [league/uri](https://github.com/thephpleague/uri). Released versions stay on Packagist, so existing installs keep working. ## License MIT. See LICENSE. http_build_url-1.0.2/src/000077500000000000000000000000001525217412500153255ustar00rootroot00000000000000http_build_url-1.0.2/src/http_build_url.php000066400000000000000000000107531525217412500210640ustar00rootroot00000000000000 "ftp", "host" => "ftp.example.com", "path" => "files/current/", "query" => "a=c" ), HTTP_URL_STRIP_AUTH | HTTP_URL_JOIN_PATH | HTTP_URL_JOIN_QUERY | HTTP_URL_STRIP_FRAGMENT ); $this->assertSame($expected, $actual); } public function trailingSlashProvider() { return array( array( 'http://example.com', array( 'scheme' => 'http', 'host' => 'example.com' ) ), array( 'http://example.com', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '' ) ), array( 'http://example.com/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/' ) ), array( 'http://example.com/yes', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => 'yes' ) ), array( 'http://example.com/yes', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/yes' ) ), array( 'http://example.com:81?a=b', array( 'scheme' => 'http', 'host' => 'example.com', 'query' => 'a=b', 'port' => 81 ) ) ); } /** * @dataProvider trailingSlashProvider */ public function testTrailingSlash($expected, $config) { $this->assertEquals($expected, http_build_url($config)); } public function testUrlQueryArrayIsIgnored() { $expected = 'http://user:pass@www.example.com:8080/pub/index.php#files'; $url = parse_url($this->full_url); parse_str($url['query'], $url['query']); $actual = http_build_url($url); $this->assertSame($expected, $actual); } public function testPartsQueryArrayIsIgnored() { $expected = $this->full_url; $actual = http_build_url($this->full_url, array('query' => array('foo' => 'bar'))); $this->assertSame($expected, $actual); } public function testAcceptStrings() { $expected = 'http://user:pass@foobar.com:8080/pub/index.php?a=b#files'; $actual = http_build_url($this->full_url, 'http://foobar.com:8080'); $this->assertSame($expected, $actual); } public function testAcceptArrays() { $expected = 'http://user:pass@foobar.com:8080/pub/index.php?a=b#files'; $actual = http_build_url(parse_url($this->full_url), parse_url('http://foobar.com:8080')); $this->assertSame($expected, $actual); } public function testDefaults() { $expected = $this->full_url; $actual = http_build_url($this->full_url); $this->assertSame($expected, $actual); } public function testNewUrl() { $expected = parse_url($this->full_url); http_build_url($this->full_url, null, null, $actual); $this->assertEquals($expected, $actual); } /** * @dataProvider queryProvider */ public function testJoinQuery($query, $expected) { $actual = http_build_url($this->full_url, array('query' => $query), HTTP_URL_JOIN_QUERY); $this->assertSame($expected, $actual); } /** * @dataProvider pathProvider */ public function testJoinPath($path, $expected) { $actual = http_build_url($this->full_url, array('path' => $path), HTTP_URL_JOIN_PATH); $this->assertSame($expected, $actual); } public function testJoinPathTwo() { $expected = "http://site.testing.com/preview/testing/09-2013/p04/image/15.jpg"; $actual = http_build_url( "http://site.testing.com/preview/testing/09-2013/p04/?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) { $actual = http_build_url($this->full_url, array(), constant($constant)); $this->assertSame($expected, $actual); } public function pathProvider() { return array( array('/donuts/brownies', 'http://user:pass@www.example.com:8080/donuts/brownies?a=b#files'), array('chicken/wings', 'http://user:pass@www.example.com:8080/pub/chicken/wings?a=b#files'), array('sausage/bacon/', 'http://user:pass@www.example.com:8080/pub/sausage/bacon/?a=b#files') ); } public function queryProvider() { return array( array('a=c', 'http://user:pass@www.example.com:8080/pub/index.php?a=c#files'), array('d=a', 'http://user:pass@www.example.com:8080/pub/index.php?a=b&d=a#files') ); } public function bitmaskProvider() { return array( array('HTTP_URL_REPLACE', 'http://user:pass@www.example.com:8080/pub/index.php?a=b#files'), array('HTTP_URL_JOIN_PATH', 'http://user:pass@www.example.com:8080/pub/index.php?a=b#files'), array('HTTP_URL_JOIN_QUERY', 'http://user:pass@www.example.com:8080/pub/index.php?a=b#files'), array('HTTP_URL_STRIP_USER', 'http://www.example.com:8080/pub/index.php?a=b#files'), array('HTTP_URL_STRIP_PASS', 'http://user@www.example.com:8080/pub/index.php?a=b#files'), array('HTTP_URL_STRIP_AUTH', 'http://www.example.com:8080/pub/index.php?a=b#files'), array('HTTP_URL_STRIP_PORT', 'http://user:pass@www.example.com/pub/index.php?a=b#files'), array('HTTP_URL_STRIP_PATH', 'http://user:pass@www.example.com:8080?a=b#files'), array('HTTP_URL_STRIP_QUERY', 'http://user:pass@www.example.com:8080/pub/index.php#files'), array('HTTP_URL_STRIP_FRAGMENT', 'http://user:pass@www.example.com:8080/pub/index.php?a=b'), array('HTTP_URL_STRIP_ALL', 'http://www.example.com'), ); } } http_build_url-1.0.2/tests/bootstrap.php000066400000000000000000000012621525217412500204270ustar00rootroot00000000000000=' ) ) { class_alias( 'PHPUnit\Framework\Assert', 'PHPUnit_Framework_Assert' ); class_alias( 'PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase' ); class_alias( 'PHPUnit\Framework\Error\Error', 'PHPUnit_Framework_Error' ); class_alias( 'PHPUnit\Framework\Error\Notice', 'PHPUnit_Framework_Error_Notice' ); class_alias( 'PHPUnit\Framework\Error\Warning', 'PHPUnit_Framework_Error_Warning' ); } // Past this point, tests will start