pax_global_header00006660000000000000000000000064131016530100014500gustar00rootroot0000000000000052 comment=93c273e77cb1edead0cf8bcf8cd2003428e74e37 http_build_url-1.0.1/000077500000000000000000000000001310165301000145175ustar00rootroot00000000000000http_build_url-1.0.1/.gitignore000066400000000000000000000000521310165301000165040ustar00rootroot00000000000000.DS_Store .idea build composer.lock vendorhttp_build_url-1.0.1/.travis.yml000066400000000000000000000001721310165301000166300ustar00rootroot00000000000000sudo: false language: php php: - 5.3 - 5.4 - 5.5 - 5.6 - 7.0 - 7.1 - hhvm script: phpunit --coverage-text http_build_url-1.0.1/LICENSE000066400000000000000000000020701310165301000155230ustar00rootroot00000000000000The 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.1/composer.json000066400000000000000000000007341310165301000172450ustar00rootroot00000000000000{ "name": "jakeasmith/http_build_url", "description": "Provides functionality for http_build_url() to environments without pecl_http.", "license": "MIT", "authors": [ { "name": "Jake A. Smith", "email": "theman@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.1/phpunit.xml.dist000066400000000000000000000013451310165301000176750ustar00rootroot00000000000000 ./tests ./src http_build_url-1.0.1/readme.md000066400000000000000000000023051310165301000162760ustar00rootroot00000000000000# http_build_url() for PHP [![Build Status](https://travis-ci.org/jakeasmith/http_build_url.png)](https://travis-ci.org/jakeasmith/http_build_url) [![Code Climate](https://codeclimate.com/github/jakeasmith/http_build_url/badges/gpa.svg)](https://codeclimate.com/github/jakeasmith/http_build_url) [![Latest Stable Version](https://poser.pugx.org/jakeasmith/http_build_url/v/stable.png)](https://packagist.org/packages/jakeasmith/http_build_url) [![Total Downloads](https://poser.pugx.org/jakeasmith/http_build_url/downloads.png)](https://packagist.org/packages/jakeasmith/http_build_url) This simple library provides functionality for [`http_build_url()`](http://us2.php.net/manual/en/function.http-build-url.php) to environments without pecl_http. It aims to mimic the functionality of the pecl function in every way and ships with a full suite of tests that have been run against both the original function and the one in this package. ## Installation The easiest way to install this library is to use [Composer](https://getcomposer.org/) from the command line. ``` $ composer require jakeasmith/http_build_url ^1 ``` ## License This project is licensed under the MIT License - see the LICENSE file for details. http_build_url-1.0.1/src/000077500000000000000000000000001310165301000153065ustar00rootroot00000000000000http_build_url-1.0.1/src/http_build_url.php000066400000000000000000000107531310165301000210450ustar00rootroot00000000000000 "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.1/tests/bootstrap.php000066400000000000000000000012621310165301000204100ustar00rootroot00000000000000=' ) ) { 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