summaryrefslogtreecommitdiff
path: root/compojure-3.2/src/compojure/http/routes.clj
diff options
context:
space:
mode:
authorsostler <sbostler@gmail.com>2010-04-11 16:47:38 -0400
committersostler <sbostler@gmail.com>2010-04-11 16:47:38 -0400
commit57be29ee7b7782830cf981d9437b18c88620f8ed (patch)
tree5ee36d1438298feb2ffefd584b9ec8b7ebd5d20a /compojure-3.2/src/compojure/http/routes.clj
parent8011da4e04a44d6245f7f5e1750c0c627b41e182 (diff)
Case insensitive route matching for literals
Diffstat (limited to 'compojure-3.2/src/compojure/http/routes.clj')
-rwxr-xr-xcompojure-3.2/src/compojure/http/routes.clj15
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