diff options
| author | sostler <sbostler@gmail.com> | 2010-04-11 16:47:38 -0400 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-04-11 16:47:38 -0400 |
| commit | 57be29ee7b7782830cf981d9437b18c88620f8ed (patch) | |
| tree | 5ee36d1438298feb2ffefd584b9ec8b7ebd5d20a /compojure-3.2/src | |
| parent | 8011da4e04a44d6245f7f5e1750c0c627b41e182 (diff) | |
Case insensitive route matching for literals
Diffstat (limited to 'compojure-3.2/src')
| -rwxr-xr-x | compojure-3.2/src/compojure/http/routes.clj | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/compojure-3.2/src/compojure/http/routes.clj b/compojure-3.2/src/compojure/http/routes.clj index d722a57..4592885 100755 --- a/compojure-3.2/src/compojure/http/routes.clj +++ b/compojure-3.2/src/compojure/http/routes.clj @@ -53,6 +53,9 @@ :regex :keywords) +(defn caseless-re-pattern [s] + (re-pattern (str "(?i)" s))) + (defn compile-uri-matcher "Compile a path string using the routes syntax into a uri-matcher struct." [path] @@ -60,12 +63,12 @@ word #":([A-Za-z][\w-]*)" literal #"(:[^A-Za-z*]|[^:*])+"] (struct uri-matcher - (re-pattern - (apply str - (lex path - splat "(.*?)" - word "([^/.,;?]+)" - literal #(re-escape (.group %))))) + (caseless-re-pattern + (apply str + (lex path + splat "(.*?)" + word "([^/.,;?]+)" + literal #(re-escape (.group %))))) (vec (remove nil? (lex path |
