You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue came up while I tried to setup a case insensitive PatternSegment in my routing table.
Clojurescript re-pattern implementation handle's java style regex flags by picking them off the front of the string and building a compatible js/RegExp object.
(defn re-pattern
"Returns an instance of RegExp which has compiled the provided string."
[s]
(if (instance? js/RegExp s)
s
(let [[prefix flags] (re-find #"^\(\?([idmsux]*)\)" s)
pattern (subs s (count prefix))]
(js/RegExp. pattern (or flags "")))))
This means a case insensitive route could be written as ["/" {#"(?i)Foo" ::foo}].
Currently this doesn't work because the regex is wrapped in parens before use.
This means the regex string doesn't start with the regex flags anymore. (?i)Foo becomes ((?i)Foo)(.*) but we need (?i)(Foo)(.*)
Possible fixes:
global "case insensitive" mode. update match-beginning to use flag and prefix "(?i)" if needed.
use helper to change the RegExp PatternSegment so that regex flags are respected. So that (?i)Foo becomes (?i)(Foo). Use this helper when making match-beginning calls.
The text was updated successfully, but these errors were encountered:
This issue came up while I tried to setup a case insensitive PatternSegment in my routing table.
Clojurescript re-pattern implementation handle's java style regex flags by picking them off the front of the string and building a compatible js/RegExp object.
This means a case insensitive route could be written as
["/" {#"(?i)Foo" ::foo}]
.Currently this doesn't work because the regex is wrapped in parens before use.
(match-beginning (str "(" (segment-regex-group this) ")") env)
(re-pattern (str regex-pattern "(.*)"))
This means the regex string doesn't start with the regex flags anymore.
(?i)Foo
becomes((?i)Foo)(.*)
but we need(?i)(Foo)(.*)
Possible fixes:
(?i)Foo
becomes(?i)(Foo)
. Use this helper when making match-beginning calls.The text was updated successfully, but these errors were encountered: