substitute: Gracefully handle trailing slashes in URLs.

Previously, using something like
"--substitute-urls=http://example.org///" would lead to a
'cache-narinfo!' call with #f as its second argument.

It would also do the wrong thing for URLs with a non-empty initial path
component, such as "http://example.org/foo/bar".

* guix/scripts/substitute.scm (fetch-narinfos)[handle-narinfo-response]:
Add call to 'basename' for PATH.
master
Ludovic Courtès 2016-07-14 15:19:07 +02:00
parent 6619f9c769
commit a7a3b39060
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 2 additions and 1 deletions

View File

@ -610,7 +610,8 @@ if file doesn't exist, and the narinfo otherwise."
(update-progress!)
(cons narinfo result))
(let* ((path (uri-path (request-uri request)))
(hash-part (string-drop-right path 8))) ; drop ".narinfo"
(hash-part (basename
(string-drop-right path 8)))) ;drop ".narinfo"
(if len
(get-bytevector-n port len)
(read-to-eof port))