Should pattern matching be case sensitive or insensitive? #39
Replies: 1 comment
-
I think this would be a valuable addition. And considering the Regex patterns are supported in a large extent for Also, to support case-insensitive match in user-land would be a bit troublesome in the present state of the proposal. For example, to support case-insensitive match for the path Another memory-friendly way would be to register something like this:
Considering the hairy situations that may arise, I think it might be best to support a flag to enable case-insenitive matches. Broadly speaking, it will be synonymous to specifying the case-insensitive flag for regex; for example: |
Beta Was this translation helpful? Give feedback.
-
By default path-to-regexp matches using a case-insensitive mode.
Currently URLPattern uses case-sensitive matching instead. This was chosen because most URL components are case sensitive at it seems important to be able to distinguish between URLs that the server may handle differently. The hostname passed to
test()
andexec()
, however, is normalized to be lower case, so pattern matching hostnames is effectively case-insensitive.We could offer an option to enable case-insensitive matching, but it would be nice not to have these kinds of options in the API if we can avoid it.
What do you think? Do we need a case-insensitive mode?
(Note, this is also discussed in #28, but we would like to collect community feedback in the discussion and then summarize in the issue.)
Beta Was this translation helpful? Give feedback.
All reactions