Coder Social home page Coder Social logo

http_build_url's Issues

HELP: New maintainer needed

I haven't written PHP in years and it seems there are people still using this. If someone from the PHP community is interested in taking over this I will happily hand it over. This package does have a surprising amount of monthly downloads, so while I don't have a particular process in mind, it would be good to see a few people vouch for the new maintainer.

HTTP_URL_JOIN_PATH incorrectly truncates trailing directory

Given the following test case:

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",
        ['path' => 'image/15.jpg'],
        HTTP_URL_JOIN_PATH | HTTP_URL_STRIP_FRAGMENT | HTTP_URL_STRIP_QUERY
    );

    $this->assertSame($expected, $actual);
}

I expect to get http://site.testing.com/preview/testing/09-2013/p04/image/15.jpg
I actually get http://site.testing.com/preview/testing/09-2013/image/15.jpg

How to autoload it?

@jakeasmith:
Installed this composer package: composer require jakeasmith/http_build_url ^1

How to autoload it? I can't rely on hardcoded paths to the PHP file.
use jakeasmith\http_build_url; doesn't work as PHP still can't find the http_build_url method.

URLs with trailing slashes lose all their a's when joined

Example:

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
);

Results in:

'http://site.testing.com/preview/testing//09-2013/p04/image/15.jpg'

Unclear license

Hey Jake - great implementation and useful library. Would it be possible for you to include an explicit license?

Maybe a bug - http_build_url([ 'user' => 'abc', 'pass' => 123]);

Hello,
I'm sorry, I don't know if this is a real bug,
and if the original function (of pecl) has same output, i never work with it

Anyway:

http_build_url([ 'user' => 'abc', 'pass' => 123]);
abc:123@/

I'm not sure if @/
are correct for output...
Can something check in original pecl version ?

Relative path generates invalid URL

Somehow this doesn't seem like it's working correctly

http_build_url(array(
  'scheme' => 'http',
  'host'   => 'example.com',
  'path'   => 'yes'
));

Output

http://example.comyes

Expected Output

http://example.com/yes

Feel free to nuke this issue if this is the intended behavior

Slash preprended when not needed

Given this configuration
['scheme' => 'http', 'host' => 'example.com']

I'm expecting this output http://example.com but http://example.com/ is given

Same goes for ['scheme' => 'http', 'host' => 'example.com', 'path' => '']

empty ['path']

I think the code:

if (isset($url['path'])) {
  $parsed_string .= $url['path'];
} else {
  $parsed_string .= '/';
}

should be replaced with:

if (!empty($url['path'])) {
  $parsed_string .= $url['path'];
} else {
  $parsed_string .= '/';
}

because if $url['path'] element is empty - we won't get '/' at the end of the url, which is required by the original behavior.

Adding an empty array for query part append wrong query params

Reproduce:

Example url: "www.example.com/?authtoken=1234"

If we try to remove the authtoken params like so

$urlParts = parse_url($url);
$queryParameters = array();
parse_str($urlParts['query'], $queryParameters);
unset($queryParameters['authtoken']);
$urlParts['query'] = $queryParameters;
$newUrl = http_build_url($urlParts);

The new url is:

"www.example.com/?Array"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.