1
0
Fork 0

- fixed 'uri:normalize-path';

- [gemini] cleaned paths when exploring local tree.
This commit is contained in:
cage 2021-03-28 16:43:21 +02:00
parent e2a9016607
commit ef3724e986
3 changed files with 12 additions and 8 deletions

View File

@ -1017,8 +1017,9 @@
((gemini-client:absolute-gemini-url-p url)
(gemini-viewer:request url :use-cached-file-if-exists use-cached-file-if-exists))
((fs:dirp url)
(let* ((index-path (fs:prepend-pwd url))
(all-paths (fs:collect-children index-path))
(let* ((index-path (uri:normalize-path (fs:prepend-pwd url)))
(all-paths (mapcar #'uri:normalize-path
(fs:collect-children index-path)))
(raw-text (with-output-to-string (stream)
(write-sequence (gemini-parser:geminize-h1
(format nil

View File

@ -75,5 +75,6 @@
(deftest test-normalize-path (uri-suite)
(assert-true (normalize "/a/x" "/a/x"))
(assert-true (normalize "/a/../b/x" "/b/x"))
(assert-true (normalize "/a/../b/x/.." "/b/x/"))
(assert-true (normalize "/a/../b/x/." "/b/x/")))
(assert-true (normalize "/a/../b/x/.." "/b/"))
(assert-true (normalize "/a/../b/x/." "/b/x/"))
(assert-true (normalize "/a/b/c/./../../g" "/a/g")))

View File

@ -349,13 +349,15 @@
(let ((popped (stack:stack-pop input-stack)))
(cond
((and (string= popped "..")
(not (stack:stack-empty-p output-stack))
(not (stack:stack-empty-p input-stack)))
(stack:stack-pop output-stack))
(not (stack:stack-empty-p output-stack)))
(stack:stack-pop output-stack)
(when (stack:stack-empty-p input-stack)
(setf ends-with-dots t)))
((and (or (string= popped "..")
(string= popped "."))
(stack:stack-empty-p input-stack))
(setf ends-with-dots t))
(setf ends-with-dots t)
(stack:stack-push output-stack "/"))
((and (string/= popped ".")
(string/= popped ".."))
(stack:stack-push output-stack popped))))