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.
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.