fukamachi / lack

Lack, the core of Clack
MIT License
155 stars 33 forks source link

:mount with a trailing slash in the path no longer works for prefixes #50

Open white-flame opened 3 years ago

white-flame commented 3 years ago

Examples using other middlewares like :static show a trailing slash in the URL prefix, but apparently it breaks :mount. The aref in line 20 of mount.lisp gets off by 1 if the slash is there, and only exact matching works in that case.

My little example below shows the problem. /test/foo hits main, /test/ hits sub. Ideally, the inclusion or disinclusion of trailing slash would be either both supported, or consistent between middlewares/examples.

Thanks!

(defvar *webserver*)
(defun start-webserver ()
  (unless *webserver*
    (setf *webserver* (clack:clackup
                       (lack:builder
                        (:mount "/test/" (lambda (env)
                                           (declare (ignore env))
                                           (list 200 nil '("sub"))))
                        (lambda (env)
                          (declare (ignore env))
                          (list 200 nil '("main"))))
                       :port 8080))))