Giter Site home page Giter Site logo

Comments (4)

jeremyroman avatar jeremyroman commented on June 6, 2024

FWIW I don't have a strong preference but I think allowing it to existing in both places is potentially confusing. What does new URLPattern({ pathname: '/foo/bar', baseURL: 'https://example.com/'}, 'https://example.net/') do?

from urlpattern.

wanderview avatar wanderview commented on June 6, 2024

I don't support that for constructor currently. But I did just add support for it to test() and exec(). The webidl looks like:

boolean test(URLPatternInit input);
boolean test(USVString input, optional USVString baseURL);

Which means passing a second argument will coerce the first argument to a string. If the first arg is an init dictionary it pretty much won't be a valid URL. So this will always return false:

pattern.test({ pathname: '/foo/bar' }, 'https://example.com');

I could change this outcome to an exception with a human readable error message if I switched the webidl to:

typedef (USVString or URLPatternInit) URLPatternInput;
boolean test(URLPatternInput input, optional USVString baseURL);

But I chose not to do that since it seemed better to make the webidl reflect the intent of correct usage. I don't feel too strongly here if other think we should go a different way.

from urlpattern.

wanderview avatar wanderview commented on June 6, 2024

Talked with @domenic this morning and he suggested we go with the union type to provide a more meaningful exception. It provides a better experience for developers at the cost of a slightly harder to read spec. We can add a note to the spec, though.

I think we should not support second baseURL argument for structured input for now. We will throw an exception if the user tries. If we get lots of requests for the feature, though, we can re-assess.

from urlpattern.

wanderview avatar wanderview commented on June 6, 2024

This is now codified in the spec.

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.