From 51a2c21f57b3ff3fce3ab7c3c2a9e4985f45258a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 31 Mar 2020 00:40:39 +0200 Subject: Change url-parsing so '.' is a delimiter. --- module/entry-points/server.scm | 15 ++++++++++----- module/server/macro.scm | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'module') diff --git a/module/entry-points/server.scm b/module/entry-points/server.scm index c072d18b..0b9512fc 100644 --- a/module/entry-points/server.scm +++ b/module/entry-points/server.scm @@ -54,12 +54,17 @@ (sxml->xml-string (directory-table "static/")))) - (GET "/static/:filename" (filename) + (GET "/static/:filename.css" (filename) (return - `((content-type ,(case (string->symbol (file-extension filename)) - ((js) 'text/javascript) - ((css) 'text/css)))) - (call-with-input-file (string-append "static/" filename) read-string))) + `((content-type text/css)) + (call-with-input-file (string-append "static/" filename ".css") + read-string))) + + (GET "/static/:filename.js" (filename) + (return + `((content-type text/javascript)) + (call-with-input-file (string-append "static/" filename ".js") + read-string))) (GET "/count" () ;; (sleep 1) diff --git a/module/server/macro.scm b/module/server/macro.scm index 123fc468..e325401a 100644 --- a/module/server/macro.scm +++ b/module/server/macro.scm @@ -10,7 +10,7 @@ (define-public (parse-endpoint-string str) - (let ((rx (make-regexp ":([^/]+)"))) + (let ((rx (make-regexp ":([^/.]+)"))) (let loop ((str str) (string "") (tokens '())) @@ -18,7 +18,7 @@ (if (not m) (values (string-append string str) (reverse tokens)) (loop (match:suffix m) - (string-append string (match:prefix m) "([^/]+)") + (string-append string (match:prefix m) "([^/.]+)") (cons (string->symbol (match:substring m 1)) tokens))))))) -- cgit v1.2.3