Should patterns be automatically encoded and normalized? #37
wanderview
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The
URL()
constructor does a number of automatic transformations to make a URL canonical. For example:/./
and/../
in pathnames. Developers often rely upon this when they begin relative pathnames with./
.new URL('http://foo:80').port
evaluates to the empty string.Currently URLPattern only performs these normalization steps on the input to
test()
andexec()
. Patterns passed to theURLPattern()
constructor are not normalized in any way. This means that developers must write their patterns to target canonical URL output manually.We could possibly perform some normalization for patterns, but not in all cases. For example, if a pattern contains
([é])
we cannot safely expand this to([%C3%A9])
since it completely changes the meaning of the regular expression. Any normalization would like only take effect outside of regular expression groupings in patterns.What do you think? Would some normalization be preferable even if its not able to be applied universally?
(Note, this is also discussed in #33, 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