Skip to content

Component match results are not intuitive for patterns with RegExp having named-capture groups #284

Description

@azaika

What is the issue with the URL Pattern Standard?

The "create a component match result" algorithm (link) expects the "group name list" and "groups" to have the same length when reconstructing the name from the RegExp match results at step 5.1.

However, when the input pattern has any RegExp parts with named-capture groups, the correspondence becomes inaccurate and results in a very non-intuitive output. For example, new URLPattern({pathname: "/:foo((?<x>xxx))/:bar"}).exec({pathname: "/xxx/yyy"}) results in :bar matches to xxx, which is for the ?<x> RegExp group as the RegExpBuiltinExec output, not yyy.

Image

The original firefox issue (found this behavior first): https://bugzilla.mozilla.org/show_bug.cgi?id=2020156

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions