Commit 59abcac3d77e7dd064de911c082d4dcb5b7d5287

Thomas de Grivel 2014-06-28T18:09:32

Fix URI templates regex with * or +

diff --git a/uri-template.lisp b/uri-template.lisp
index 591b36e..137dd4c 100644
--- a/uri-template.lisp
+++ b/uri-template.lisp
@@ -384,6 +384,11 @@ URI-TEMPLATE."
       #1=(:greedy-repetition 1 nil ,char-regex)
       (:non-greedy-repetition 0 nil (:sequence ,(op-separator op) #1#)))))
 
+(defun var-name (var)
+  (if (consp var)
+      (string (second var))
+      (string var)))
+
 (defun uri-template-regex (template)
   (let ((vars))
     (values
@@ -394,7 +399,7 @@ URI-TEMPLATE."
 	     `(:sequence
 	       ,@(when (op-prefix op) `(,(op-prefix op)))
 	       ,@(reduce (lambda (exp var)
-			   `((:named-register ,(string var)
+			   `((:named-register ,(var-name var)
 					      ,(var-regex op var))
 			     ,@(when exp `((:greedy-repetition
 					    0 1 (:sequence ,(op-separator op)