From 57be29ee7b7782830cf981d9437b18c88620f8ed Mon Sep 17 00:00:00 2001 From: sostler Date: Sun, 11 Apr 2010 16:47:38 -0400 Subject: Case insensitive route matching for literals --- compojure-3.2/src/compojure/http/routes.clj | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'compojure-3.2/src') 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 -- cgit v1.2.3-70-g09d2