Comments (4)
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.
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.
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.
This is now codified in the spec.
from urlpattern.
Related Issues (20)
- Base URL inheritance gives unintuitive results HOT 21
- Consider creating a RFC for base functionality HOT 2
- Add a "using URLPattern in other APIs" section HOT 9
- Backslash escaping is required for colon before password in string syntax
- WHATWG migration HOT 5
- Attribute to show the regular expression usage. HOT 9
- Hash test matching different from path matching HOT 1
- Consider cleaning up extra markdown documents
- Custom named full-wildcard HOT 2
- Base URL and empty pathname in URLPatternInit
- Incorrect handling of base URL in URLPatternInit processing HOT 10
- Loose base URL check can crash URL parser HOT 5
- Handling of special character in hostname
- More consistent and robust segment wilcard generation
- Incorrect type in group name assignment
- "Hostname pattern is an IPv6 address" called with `null` HOT 1
- Constructor string parser has confusing result for paths containing a colon. HOT 1
- The way to integrate the API without depending on ECMAScript realm. HOT 3
- Accept URL as the match algorithm's input. HOT 4
- Opaque Host and domain encoding HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from urlpattern.