Giter Club home page Giter Club logo

Comments (8)

mtdowling avatar mtdowling commented on May 1, 2024

Can you provide a concrete example?

Please note thought that one of the things I want to avoid is having to implement a custom URI parser to account for things like this. It would be slow and would be a maintenance burden. If this ends up being a limitation of PHP's parse_url, then I think we would just chalk it up as a "known issue".

from psr7.

mihai-stancu avatar mihai-stancu commented on May 1, 2024

I've experimented some more and found even more constraints to the condition. Now I'm pretty sure this should be a known issue.

I'll update the initial description with the further constraints and an example.

FWIW: My particular use case was a RESTful API with an resource id of the format <class>:<id> specified in the URL.

Working around this problem is fairly easy: either specify a query or a fragment or at least leave a dangling question mark at the end.

from psr7.

mihai-stancu avatar mihai-stancu commented on May 1, 2024

Should I close the issue or will you close it with a particular status/label?

from psr7.

mtdowling avatar mtdowling commented on May 1, 2024

Hm... I wonder if there's something we can do here, at least for the case of combining URIs... For example, maybe we can have a special case for combining with a relative URI that starts with '/'?

from psr7.

mihai-stancu avatar mihai-stancu commented on May 1, 2024

Simple fix would be (in the context of initializing relative paths) to add a question mark if one is not already present.

        if (!($rel instanceof UriInterface)) {
            $rel = ($rel[0] === '/' and strpos($rel, '?') === false) ? $rel.'?' : $rel;
            $rel = new self($rel);
        }

from psr7.

Tobion avatar Tobion commented on May 1, 2024

Is there a PHP bug report for this? https://3v4l.org/QMNeo definitely seems like a PHP bug.

from psr7.

mihai-stancu avatar mihai-stancu commented on May 1, 2024

@Tobion not one that I found but parse_url might very well have been intended to parse complete URLs (containing scheme, authentication, domain, tld, port, path, query, fragment, etc.).

Using parse_url for relative paths could be regarded as improper usage. Which is why I didn't pursue it as a PHP bug per se.

from psr7.

Tobion avatar Tobion commented on May 1, 2024

But it parses relative urls correctly for the most part like //example.org and /path. So either it parses only absolute URIs and needs to return false for anything else. Or it must parse relative URIs correctly as well.

from psr7.

Related Issues (20)

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.