unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] utils: file-extension should work with urls.
@ 2016-12-14 15:25 David Craven
  2016-12-14 15:26 ` David Craven
  0 siblings, 1 reply; 4+ messages in thread
From: David Craven @ 2016-12-14 15:25 UTC (permalink / raw)
  To: guix-devel

* 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-15  5:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-14 15:25 [PATCH] utils: file-extension should work with urls David Craven
2016-12-14 15:26 ` David Craven
2016-12-15  4:27   ` David Craven
2016-12-15  5:01     ` David Craven

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).