aboutsummaryrefslogtreecommitdiff
path: root/module/hnh
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-06-23 03:57:23 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-06-23 03:57:23 +0200
commite08fd73f1d8e84540d5ebdc5fdf98c047da0976e (patch)
treedc8381d2cbeb79e1527102c3b2082fe66dfdd96b /module/hnh
parentDocument filename-extension and realpath. (diff)
downloadcalp-e08fd73f1d8e84540d5ebdc5fdf98c047da0976e.tar.gz
calp-e08fd73f1d8e84540d5ebdc5fdf98c047da0976e.tar.xz
Wrote (and fixed) tests for filename-extension.
Diffstat (limited to 'module/hnh')
-rw-r--r--module/hnh/util/path.scm8
1 files changed, 7 insertions, 1 deletions
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)