From 5e5dc5d9fdfdff555007d84586cfda3832e020f6 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 17 Nov 2020 08:25:43 -0800 Subject: [PATCH] handle relative path correctly (fixes #241) --- pollen/pagetree.rkt | 12 +++++++++++- pollen/private/ts.rktd | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pollen/pagetree.rkt b/pollen/pagetree.rkt index 1354f61..dbcb9cf 100644 --- a/pollen/pagetree.rkt +++ b/pollen/pagetree.rkt @@ -304,7 +304,17 @@ (define starting-dir (match starting-path [(? directory-exists?) 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)]) diff --git a/pollen/private/ts.rktd b/pollen/private/ts.rktd index bd684d9..e9f0aa1 100644 --- a/pollen/private/ts.rktd +++ b/pollen/private/ts.rktd @@ -1 +1 @@ -1605539068 +1605630343