Giter Site home page Giter Site logo

Comments (8)

wanderview avatar wanderview commented on June 6, 2024 1

By the way, thank you for bringing this use case to my attention. There was some discussion at TPAC about limiting the effort to only pathname for now. I plan to try to press forward with the full proposal, though.

from urlpattern.

wanderview avatar wanderview commented on June 6, 2024 1

FWIW there is an existing polyfill written on top of path-to-regexp: https://github.com/kenchris/urlpattern-polyfill/blob/main/src/index.js

I expect the final URLPattern will look at a bit different (targeting newer path-to-regexp now, etc), but its possible to do all this server-side already more or less.

from urlpattern.

wanderview avatar wanderview commented on June 6, 2024

The current design does support patterns for each URL component. So your first example could be expressed as:

new URLPattern({ protocol: 'https' });

Currently the design is focused on the more granular URL components and does not have an "origin" concept. You could implement your second example like:

new URLPattern({ protocol: 'https', hostname: 'example.com' });

Or by providing a "base URL" and overriding the pathname part to be a wildcard:

new URLPattern({ baseUrl: "https://example.com", pathname: "/*" });

Maybe we can add some kind of origin short hand, but I'd like to get the basics prototyped first.

Does this meet your use cases?

from urlpattern.

shhnjk avatar shhnjk commented on June 6, 2024

Yeah, this should meet the requirement! Thanks!

from urlpattern.

shhnjk avatar shhnjk commented on June 6, 2024

No problem :) I also heard feedback from people that this will be useful in server-side as well to check request URL pattern, so some people are looking forward to use this in server-side Node JS 😀

from urlpattern.

jeremyroman avatar jeremyroman commented on June 6, 2024

The current design does support patterns for each URL component. So your first example could be expressed as:

new URLPattern({ protocol: 'https' });

Currently the design is focused on the more granular URL components and does not have an "origin" concept. You could implement your second example like:

new URLPattern({ protocol: 'https', hostname: 'example.com' });

nit: If I understand correctly this will permit https://example.com:PORT for every port, which is broader than the origin https://example.com (which is only port 443). Just mentioning this because it seems like a potential pitfall.

from urlpattern.

wanderview avatar wanderview commented on June 6, 2024

nit: If I understand correctly this will permit https://example.com:PORT for every port, which is broader than the origin https://example.com (which is only port 443). Just mentioning this because it seems like a potential pitfall.

That is currently correct. You would need to be more restrictive by including port: '(443)?' if the port restriction was important.

We might want to make some "empty string matches the default port for the port" type equivalence, but I'm a bit leery of making one of the components an exception to the "gets a wildcard by default" rule.

from urlpattern.

wanderview avatar wanderview commented on June 6, 2024

I wrote a couple related issue:

#32
#31

from urlpattern.

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.