Skip to content
Browse files

fixed Clack.Util.Route. it occurs a type error, nil is not a vector.

  • Loading branch information...
1 parent e73ec8e commit 797860fc88022ae9a930cd2eede6850e148bb960 @fukamachi committed Jun 11, 2011
Showing with 19 additions and 17 deletions.
  1. +15 −13 src/util/route.lisp
  2. +4 −4 t/util/route.lisp
View
28 src/util/route.lisp
@@ -98,17 +98,18 @@ Example:
@type string url-string
(multiple-value-bind (matchp values)
(scan-to-strings (regex this) url-string)
- (values matchp
- (loop for key in (param-keys this)
- for val across values
- if (eq key :splat)
- collect val into splat
- else
- append (list key val) into result
- finally
- (return (if splat
- `(:splat ,splat ,@result)
- result))))))
+ (when matchp
+ (values matchp
+ (loop for key in (param-keys this)
+ for val across values
+ if (eq key :splat)
+ collect val into splat
+ else
+ append (list key val) into result
+ finally
+ (return (if splat
+ `(:splat ,splat ,@result)
+ result)))))))
@export
(defmethod match ((this <regex-url-rule>) url-string)
@@ -124,8 +125,9 @@ Example:
"
(multiple-value-bind (matchp values)
(scan-to-strings (regex this) url-string)
- (values matchp
- `(:captures ,(coerce values 'list)))))
+ (when matchp
+ (values matchp
+ `(:captures ,(coerce values 'list))))))
@export
(defmethod link-to ((this <url-rule>) params)
View
8 t/util/route.lisp
@@ -31,15 +31,15 @@
(diag "normal case")
(is-match "/hello" "/hello" '("/hello" nil) "'/hello' matches '/hello'")
-(is-match "/hello" "/bye" '(nil nil) "'/hello' doesn't match '/bye'")
+(is-match "/hello" "/bye" '(nil) "'/hello' doesn't match '/bye'")
(diag "with named parameter")
(is-match "/hello/:name" "/hello/fukamachi" '("/hello/fukamachi" (:name "fukamachi"))
"match")
-(is-match "/hello/:name" "/hello/fukamachi/eitarow" '(nil nil)
+(is-match "/hello/:name" "/hello/fukamachi/eitarow" '(nil)
"containing a slash")
-(is-match "/hello/:name" "/bye/fukamachi" '(nil nil)
+(is-match "/hello/:name" "/bye/fukamachi" '(nil)
"not match")
(diag "with multiple named parameter")
@@ -83,7 +83,7 @@
(is-match "/te st/" "/te%20st/" '("/te%20st/" nil) "escape space")
(is-match "/test$/" "/test$/" '("/test$/" nil) "escape $")
(is-match "/te.st/" "/te.st/" '("/te.st/" nil) "escape .")
-(is-match "/te.st/" "/te0st/" '(nil nil) "escape .")
+(is-match "/te.st/" "/te0st/" '(nil) "escape .")
(is-match "/test(bar)/" "/test(bar)/" '("/test(bar)/" nil) "escape ()")
(finalize)

0 comments on commit 797860f

Please sign in to comment.
Something went wrong with that request. Please try again.