mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
download: Keep only one slash when concatenating URIs.
* guix/build/download.scm (url-fetch)[uri-vicinity]: New procedure. [maybe-expand-mirrors]: Use it.
This commit is contained in:
parent
5321f74f23
commit
480943dd46
1 changed files with 7 additions and 1 deletions
|
@ -135,6 +135,12 @@ (define* (url-fetch url file #:key (mirrors '()))
|
|||
"Fetch FILE from URL; URL may be either a single string, or a list of
|
||||
string denoting alternate URLs for FILE. Return #f on failure, and FILE
|
||||
on success."
|
||||
(define (uri-vicinity dir file)
|
||||
;; Concatenate DIR, slash, and FILE, keeping only one slash in between.
|
||||
;; This is required by some HTTP servers.
|
||||
(string-append (string-trim-right dir #\/) "/"
|
||||
(string-trim file #\/)))
|
||||
|
||||
(define (maybe-expand-mirrors uri)
|
||||
(case (uri-scheme uri)
|
||||
((mirror)
|
||||
|
@ -142,7 +148,7 @@ (define (maybe-expand-mirrors uri)
|
|||
(path (uri-path uri)))
|
||||
(match (assoc-ref mirrors kind)
|
||||
((mirrors ..1)
|
||||
(map (compose string->uri (cut string-append <> path))
|
||||
(map (compose string->uri (cut uri-vicinity <> path))
|
||||
mirrors))
|
||||
(_
|
||||
(error "unsupported URL mirror kind" kind uri)))))
|
||||
|
|
Loading…
Reference in a new issue