Skip to content

Custom parser to adapt URLPattern syntax fails #563

@ferbs

Description

@ferbs

Is it possible to pass Router a custom parser function that would work with the WHATWG URLPattern syntax?

I tried modifying Wouter's path-to-regex example but the example relies on parse options not available in URLPattern or path-to-regex v8.x. Eg, the example uses the end parser option to match segments but applying the closest equivalent {/*remainder} fails to match.

Beyond a custom parser function, would it make sense to add a builtin Wouter feature to support the new syntax? Eg, <Router urlpattern> or <Router crapNewSyntax> or somesuch. You wouldn't need to add path-to-regex as a dependency. You could instead mention that the option might require a polyfill. The URLPattern syntax has growing browser support, was added to Node v23.8, and is now being used as default in backend routers like Koa and Express.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions