handle relative path correctly (fixes #241)

pull/243/head
Matthew Butterick 4 years ago
parent 9bd067552d
commit 5e5dc5d9fd

@ -304,7 +304,17 @@
(define starting-dir (match starting-path (define starting-dir (match starting-path
[(? directory-exists?) starting-path] [(? directory-exists?) starting-path]
[_ (dirname starting-path)])) [_ (dirname starting-path)]))
(->output-path (find-relative-path (->complete-path starting-dir) (->complete-path path)))) (define relpath (if (eq? starting-dir 'relative)
path
(find-relative-path (->complete-path starting-dir) (->complete-path path))))
(->output-path relpath))
(module-test-external
(check-equal? (path->pagenode "/foo/bar/index.html" "/foo") 'foo/bar/index.html)
(check-equal? (path->pagenode "/foo/bar/index.html" "/foo/bar") 'bar/index.html)
(check-equal? (path->pagenode "/foo/bar/index.html" (string->path "/foo/bar")) 'bar/index.html)
(check-equal? (path->pagenode "/foo/bar/index.html" "/foo/bar/other.html") 'index.html)
(check-equal? (path->pagenode "assets" 'index.html) 'assets))
(define+provide/contract (in-pagetree? pnish [pt-or-path (current-pagetree)]) (define+provide/contract (in-pagetree? pnish [pt-or-path (current-pagetree)])

@ -1 +1 @@
1605539068 1605630343

Loading…
Cancel
Save