-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URLPattern #2286
Comments
URLPattern is designed to be slow, so we aren't going to support this officially unless it becomes a web standard (WICG != W3C). You can use JS polyfills until then |
is it not a web standard ? link |
Please reconsider this. Make it an optional import and allow us to opt into using it if we are willing to accept the performance hit. |
I would like to make http server with bun. Here: https://bun.sh/guides/http/server only trivial path matching is demonstrated. Then what is bun proposal for that? |
Routing with regexp is painful and should be abandoned |
It is great feature for web but not so for server-side |
nice to have!!! |
Currently blocking the use of cross-runtime fetch mocks like @c4spar/mock-fetch. |
NodeJS just merged support for URLPattern nodejs/node#40844. If Bun wants full Node compatibility, implementing URLPattern seems unavoidable now. |
Safari shipped URLPattern this week as well, and URLPattern made it on the Interop 2025 list. |
nodejs ship it too but i guess this feature not so important because it slow by design and etc |
We use it for routing, as a polyfill (which is 1000 times slower). I personally don't get how you people call some implementation "slow" without even asking how much calls to that function will be made. In my work perspective LLMs are slow. And all pattern matching algorithms, even the most ineffecient, are super fast 😅 |
Why u need this? Also https://en.m.wikipedia.org/wiki/ReDoS Radix-tree based routers is more fine |
@kravetsone thanks! It's an internal routing for unusual purposes. Unrelated to API, not using HTTP(s), no DOS threats.
Most likely true. But when this code was written we couldn't find a well supported and typed library (and writing one was not an option). Can you recommend any particular library? |
https://www.npmjs.com/package/find-my-way used by fastify https://www.npmjs.com/package/memoirist used by elysia https://github.com/mapljs/router by @aquapi frameworks |
@ivan-kleshnin Now you can have route patterns in Bun. |
I think My router is the fastest possible you can have in JS but I didn't implemenet named parameters, like uWS |
@aquapi this is not constructive; there are usecases that RegExp-based routers solve for that trie-based routers do not support. @ivan-kleshnin we will implement support for URLPattern in Bun (using WebKit's implementation). We haven't yet, but we will given that now it is a web standard that Safari supports and that Node implemented. |
Yes, I agree that this must be implemented, but for now it probably doesn't make sense to take special priority - there are still a lot of things that are more important for now i love u work! |
@Jarred-Sumner There are use cases but it's not worth it at all. I think URLPattern has its use cases but not for URL routing (There is a reason most frameworks in other languages don't support these patterns) Plus things like this can happen because it seems like JSC doesn't have optimizations for it yet: https://v8.dev/blog/non-backtracking-regexp https://adventures.nodeland.dev/archive/you-should-not-use-urlpattern-to-route-http/ |
@ivan-kleshnin A better solution would be whatwg/urlpattern#166 |
@aquapi please stop commenting on the issue to avoid ppl unsubscribing. URLPattern is going to be implemented. There are use cases for routing which are valid and other use cases like Paraglide JS's localization of URLs https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy#url |
@samuelstroschein I'm not against URLPattern being implemented at all. I'm just telling that you should not use it for routing. |
What is the problem this feature would solve?
https://developer.mozilla.org/en-US/docs/Web/API/URLPattern
What is the feature you are proposing to solve the problem?
Although this is an experimental function, it is undoubtedly very practical for bun routing, and deno has already implemented it, so we can't live without it.
What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: