Permalink
Browse files

Merge branch '11.07-SNAPSHOT'

  • Loading branch information...
2 parents 735075d + 3f000d5 commit ddfa519b8e93ff82adc19b65094fc77c73c35232 @fukamachi committed Jun 24, 2011
Showing with 16 additions and 15 deletions.
  1. +1 −1 clack.asd
  2. +10 −11 src/util/route.lisp
  3. +5 −3 t/util/route.lisp
View
@@ -20,7 +20,7 @@
(in-package :clack-asd)
(defsystem clack
- :version "11.06.0"
+ :version "11.07-SNAPSHOT"
:author "Eitarow Fukamachi"
:license "LLGPL"
:depends-on (;; Utility
View
@@ -53,16 +53,15 @@
(ppcre:regex-replace-all "\\(.+?\\)" (regex this) "~A")))
(defmethod compile-rule ((this <url-rule>))
- (loop with pattern = (ppcre:regex-replace-all
- "[^\\?\\%\\\\/:\\*\\w-]" (url this)
- #'escape-special-char
- :simple-calls t)
- with list = (split "(?::([\\w-]+)|(\\*))" pattern
+ (loop with list = (split "(?::([\\w-]+)|(\\*))" (url this)
:with-registers-p t :omit-unmatched-p t)
while list
for prefix = (pop list)
for name = (pop list)
- collect prefix into re
+ collect (ppcre:regex-replace-all
+ "[^\\?\\/\\w-]" prefix
+ #'escape-special-char
+ :simple-calls t) into re
collect prefix into cs
if (string= name "*")
collect :splat into names
@@ -140,11 +139,11 @@ Example:
`(:captures ,(coerce values 'list)))))))
@export
-(defmethod link-to ((this <url-rule>) params)
+(defmethod url-for ((this <url-rule>) params)
"Return an URL from a rule and parameters.
Example:
- (link-to (make-url-rule \"/hello/:name\")
+ (url-for (make-url-rule \"/hello/:name\")
'(:name \"fukamachi\"))
;=> \"/hello/fukamachi\"
"
@@ -159,11 +158,11 @@ Example:
params))
@export
-(defmethod link-to ((this <regex-url-rule>) params)
+(defmethod url-for ((this <regex-url-rule>) params)
"Return an URL from a rule and parameters.
Example:
- (link-to (make-url-rule \"/hello/:name\")
+ (url-for (make-url-rule \"/hello/:name\")
'(:name \"fukamachi\"))
;=> \"/hello/fukamachi\"
"
@@ -185,7 +184,7 @@ Clack.Util.Route - Class for Sinatra-compatible URL rule.
(match *url-rule* \"/bye/fukamachi\")
;=> NIL
- (link-to *url-rule* '(:name \"fukamachi\"))
+ (url-for *url-rule* '(:name \"fukamachi\"))
;=> \"/hello/fukamachi\"
"
View
@@ -3,7 +3,7 @@
:clack.util.route
:cl-test-more))
-(plan 22)
+(plan 23)
(defun %is-match (url-rule req-url &optional params comment)
(is (multiple-value-list (match url-rule :get req-url))
@@ -19,12 +19,12 @@
(%is-match rule req-url params comment)))
(defun is-link (url-rule params result &optional comment)
- (is (link-to (make-url-rule url-rule) params)
+ (is (url-for (make-url-rule url-rule) params)
result
comment))
(defun is-re-link (url-rule params result &optional comment)
- (is (link-to (make-url-rule url-rule :regexp t) params)
+ (is (url-for (make-url-rule url-rule :regexp t) params)
result
comment))
@@ -87,4 +87,6 @@
(is-match "/te.st/" "/te0st/" '(nil) "escape .")
(is-match "/test(bar)/" "/test(bar)/" '("/test(bar)/" nil) "escape ()")
+(is-link "/te.st/" nil "/te.st/")
+
(finalize)

0 comments on commit ddfa519

Please sign in to comment.