[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] utils: file-extension should work with urls.
From: |
David Craven |
Subject: |
[PATCH] utils: file-extension should work with urls. |
Date: |
Wed, 14 Dec 2016 16:25:07 +0100 |
* guix/utils.scm (file-extension): Detect the lack of file extensions in
urls.
---
guix/utils.scm | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/guix/utils.scm b/guix/utils.scm
index 06f49daca..2bae2eb60 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -24,6 +24,7 @@
(define-module (guix utils)
#:use-module (guix config)
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-2)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
@@ -559,8 +560,11 @@ minor version numbers from version-string."
(define (file-extension file)
"Return the extension of FILE or #f if there is none."
- (let ((dot (string-rindex file #\.)))
- (and dot (substring file (+ 1 dot) (string-length file)))))
+ (and-let* ((dot (string-rindex file #\.))
+ (ext (substring file (+ 1 dot) (string-length file))))
+ ;; Make sure that a file-extension does not contain forward
+ ;; slashes incase file is a URL.
+ (and (not (string-rindex file #\/)) ext)))
(define (file-sans-extension file)
"Return the substring of FILE without its extension, if any."
--
2.11.0
- [PATCH] utils: file-extension should work with urls.,
David Craven <=