diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-06-23 03:57:23 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-06-23 03:57:23 +0200 |
commit | e08fd73f1d8e84540d5ebdc5fdf98c047da0976e (patch) | |
tree | dc8381d2cbeb79e1527102c3b2082fe66dfdd96b /module | |
parent | Document filename-extension and realpath. (diff) | |
download | calp-e08fd73f1d8e84540d5ebdc5fdf98c047da0976e.tar.gz calp-e08fd73f1d8e84540d5ebdc5fdf98c047da0976e.tar.xz |
Wrote (and fixed) tests for filename-extension.
Diffstat (limited to '')
-rw-r--r-- | module/hnh/util/path.scm | 8 |
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) |