dev-refac-2020
Matthew Butterick 6 years ago
parent a6c0253e65
commit 942c6d7549

@ -8,10 +8,12 @@
;; this is identical to `filename-extension` in `racket/path`
;; but will not treat hidden files as an extension (which is a bug)
(define (filename-extension name)
(define filename (file-name-from-path name))
(define bytes (and filename (path->bytes filename)))
(match (and bytes (regexp-match #rx#".[.]([^.]+)$" bytes))
(match (file-name-from-path name)
[(? path-for-some-system? filename)
(=> resume)
(match (regexp-match #rx#".[.]([^.]+)$" (path->bytes filename))
[(list _ second) second]
[_ (resume)])]
[_ #false]))
(module+ test

Loading…
Cancel
Save