From: David Craven <david@craven.ch>
To: guix-devel@gnu.org
Subject: [PATCH] utils: file-extension should work with urls.
Date: Wed, 14 Dec 2016 16:25:07 +0100 [thread overview]
Message-ID: <20161214152507.17677-1-david@craven.ch> (raw)
* 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
next reply other threads:[~2016-12-14 15:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-14 15:25 David Craven [this message]
2016-12-14 15:26 ` [PATCH] utils: file-extension should work with urls David Craven
2016-12-15 4:27 ` David Craven
2016-12-15 5:01 ` David Craven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161214152507.17677-1-david@craven.ch \
--to=david@craven.ch \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).