From e08fd73f1d8e84540d5ebdc5fdf98c047da0976e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 23 Jun 2022 03:57:23 +0200 Subject: Wrote (and fixed) tests for filename-extension. --- module/hnh/util/path.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'module/hnh/util') diff --git a/module/hnh/util/path.scm b/module/hnh/util/path.scm index ac6df491..ea081e85 100644 --- a/module/hnh/util/path.scm +++ b/module/hnh/util/path.scm @@ -66,7 +66,13 @@ (char=? #\. (string-ref base 0)))) (define (filename-extension filename) - (car (reverse (string-split filename #\.)))) + (let ((components (-> filename + ;; Path split removes potential trailing directory separator + path-split last + basename + (string-split #\.)))) + (if (>= 1 (length components)) + "" (last components)))) (define (realpath filename) (unless (string? filename) -- cgit v1.2.3