aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoin Okay <cbeok@protonmail.com>2020-04-22 16:22:03 -0500
committerCoin Okay <cbeok@protonmail.com>2020-04-22 16:22:03 -0500
commit22258951c45d89a19bde494acd5510ad48ae1d0e (patch)
tree430d2d99de8f58f4ce121241dce0717b2c500c6a
parent181b3a713ffb3cbae7724a6ab0b4a1f94f6653dd (diff)
route lookup fix
the route key and the req key must be equal in length
-rw-r--r--lazybones.lisp26
1 files changed, 14 insertions, 12 deletions
diff --git a/lazybones.lisp b/lazybones.lisp
index 8c0d1b4..4924b84 100644
--- a/lazybones.lisp
+++ b/lazybones.lisp
@@ -187,18 +187,20 @@ already extant route key.
Returns two values, a possible argument list to pass to the route
handler and a boolean indicating success"
- (let (args)
- (loop
- :for req-part :in req-key
- :for route-part :in route-key
- :do (cond
- ((path-var-p route-part)
- (push req-part args))
-
- ((not (route-part-match-p req-part route-part))
- (return-from match-route-key (values nil nil)))))
-
- (values (reverse args) t)))
+ (if (not (= (length req-key) (length route-key)))
+ (values nil nil)
+ (let (args)
+ (loop
+ :for req-part :in req-key
+ :for route-part :in route-key
+ :do (cond
+ ((path-var-p route-part)
+ (push req-part args))
+
+ ((not (route-part-match-p req-part route-part))
+ (return-from match-route-key (values nil nil)))))
+
+ (values (reverse args) t))))
(defun lookup-route (req)