Can't route url which contains some char likes #\space
When visit something like 127.0.0.1/a%20a it will give error like this:
There was an error processing your request: Parse error:URI "/a a" contains illegal character #\ at position 2.%
It turns out to because this.
Clack will return decoded url, which may contains something like #\space and it looks like puri(puri:parse-uri) can't handle it.
It may have more to do with cl-routes, but it looks like there are no new progress since 2017.
If Clack returns the decoded URL, then probably we don't need to decode it again.
I have tried
(defun get-route (path)
"Returns a route, matched on given path.
If none matched, then returns nil.
Path should be a string."
(check-type path string)
(routes:match *routes* (quri:url-encode path)))
But it doesn't work, since quri:url-encode will encode / into %2F, leads different results.
For example, try this:
(puri:uri-parsed-path (puri:parse-uri "/Attic/Media/wallpaper/81566390_pa0.png"))
(puri:uri-parsed-path (puri:parse-uri (quri:url-encode "/Attic/Media/wallpaper/81566390_pa0.png")))
I can't find function from puri to process this. Maybe write another function on it?
I have noticed that there are two routes system in weblocks.
One is routes.lisp, inside weblocks, another is weblocks-navigation-widget.
Why is there even two?
Is it possible to merge them into one? Is there any benefit doing so?
For now, I use this as a work around:
(defun get-route (path)
"Returns a route, matched on given path.
If none matched, then returns nil.
Path should be a string."
(check-type path string)
(routes:match *routes* (cl-strings:replace-all (quri:url-encode path) "%2F" "/")))
But it may not handle case I mentioned here