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

Loading…
Cancel
Save