cripslock

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 04feb1138d79d5408574f0598f7045ecde4ee1d8
parent 7e178d05010e26b348859c704e7edd386c8dd6b0
Author: Daniel Barlow <dan@telent.net>
Date:   Tue, 22 Jul 2025 18:04:16 +0100

static-path-if-safe checks the file exists

Diffstat:
Msite.fnl | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/site.fnl b/site.fnl @@ -118,7 +118,7 @@ (fn static-path-if-safe [basedir name] (let [prefix (realpath basedir) fullpath (realpath (.. basedir name))] - (and (string.find fullpath prefix 1 true) fullpath))) + (and fullpath (string.find fullpath prefix 1 true) fullpath))) (fn for-pathname [path] (let [posts (index-posts path)] @@ -132,6 +132,7 @@ (define-tests :static-path (expect (static-path-if-safe "./" "/README.md")) - (expect (not (static-path-if-safe "./tests/" "../README.md")))) + (expect (not (static-path-if-safe "./tests/" "../README.md"))) + (expect (not (static-path-if-safe "./tests/" "no such file")))) { : for-pathname }