aboutsummaryrefslogtreecommitdiff
path: root/module/server/macro.scm
diff options
context:
space:
mode:
Diffstat (limited to 'module/server/macro.scm')
-rw-r--r--module/server/macro.scm17
1 files changed, 15 insertions, 2 deletions
diff --git a/module/server/macro.scm b/module/server/macro.scm
index b9ce94bb..28565c3b 100644
--- a/module/server/macro.scm
+++ b/module/server/macro.scm
@@ -9,15 +9,28 @@
(define-public (parse-endpoint-string str)
- (let ((rx (make-regexp ":([^/.]+)")))
+ (let ((rx (make-regexp ":([^/.]+)(\\{([^}]+)\\})?([.])?")))
(let loop ((str str)
(string "")
(tokens '()))
(let ((m (regexp-exec rx str 0)))
(if (not m)
+ ;; done
(values (string-append string str) (reverse tokens))
+
(loop (match:suffix m)
- (string-append string (match:prefix m) "([^/.]+)")
+ (string-append string (match:prefix m)
+ (aif (match:substring m 3)
+ (string-append "(" it ")")
+ "([^/.]+)")
+ ;; period directly following matched variable.
+ ;; since many variables break on period, we often
+ ;; want to match a literal period directly after them.
+ ;; Ideally all periods outside of pattern should be
+ ;; matched literally, but that's harder to implement.
+ (regexp-quote
+ (aif (match:substring m 4)
+ "." "")))
(cons (string->symbol (match:substring m 1))
tokens)))))))