Permalink
Browse files

Patch from Janico Greifenberg to support i18n characters in routes

  • Loading branch information...
1 parent 70e0eb7 commit d511730ceaf72f81dd1f583d569d52f14a603032 @weavejester weavejester committed Nov 2, 2010
Showing with 11 additions and 2 deletions.
  1. +2 −2 src/clout/core.clj
  2. +9 −0 test/clout/test/core.clj
View
@@ -86,8 +86,8 @@
(route-compile path {}))
([path regexs]
(let [splat #"\*"
- word #":([A-Za-z_][\w-]*)"
- literal #"(:[^A-Za-z_*]|[^:*])+"
+ word #":([\p{L}_][\p{L}_0-9-]*)"
+ literal #"(:[^\p{L}_*]|[^:*])+"
word-group #(.group % 1)
word-regex #(regexs (keyword (word-group %))
"[^/.,;?]+")]
@@ -44,6 +44,15 @@
"/:x/:x/:x" "/a/b/c" {"x" ["a" "b" "c"]}
"/:x/b/:x" "/a/b/c" {"x" ["a" "c"]}))
+(deftest non-ascii-keywords
+ (are [path uri params] (= (route-matches path uri) params)
+ "/:äñßOÔ" "/abc" {"äñßOÔ" "abc"}
+ "/:ÁäñßOÔ" "/abc" {"ÁäñßOÔ" "abc"}
+ "/:ä/:ش" "/foo/bar" {"ä" "foo" "ش" "bar"}
+ "/:ä/:ä" "/foo/bar" {"ä" ["foo" "bar"]}
+ "/:Ä-ü" "/baz" {"Ä-ü" "baz"}
+ "/:Ä_ü" "/baz" {"Ä_ü" "baz"}))
+
(deftest wildcard-paths
(are [path uri params] (= (route-matches path uri) params)
"/*" "/foo" {"*" "foo"}

0 comments on commit d511730

Please sign in to comment.