* [bug#39753] [PATCH] guix: swh: Handle absolute URLs being returned by the API.
@ 2020-02-23 11:20 Jakub Kądziołka
0 siblings, 0 replies; only message in thread
From: Jakub Kądziołka @ 2020-02-23 11:20 UTC (permalink / raw)
To: 39753
* guix/swh.scm (swh-url): Don't prepend (%swh-base-url) if a domain is
already present.
This fixes the "guix lint: warning: while connecting to Software Heritage:
host lookup failure: Name or service not known" error message.
---
guix/swh.scm | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/guix/swh.scm b/guix/swh.scm
index 8bdf9965f6..a948a8f28f 100644
--- a/guix/swh.scm
+++ b/guix/swh.scm
@@ -126,9 +126,16 @@
(make-parameter "https://archive.softwareheritage.org"))
(define (swh-url path . rest)
+ ;; URLs returned by the API may be relative or absolute. This has changed
+ ;; without notice before. Handle both cases by detecting whether the path
+ ;; starts with a domain.
+ (define root
+ (if (string-prefix? "/" path)
+ (string-append (%swh-base-url) path)
+ path))
+
(define url
- (string-append (%swh-base-url) path
- (string-join rest "/" 'prefix)))
+ (string-append root (string-join rest "/" 'prefix)))
;; Ensure there's a trailing slash or we get a redirect.
(if (string-suffix? "/" url)
--
2.25.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-23 11:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-23 11:20 [bug#39753] [PATCH] guix: swh: Handle absolute URLs being returned by the API Jakub Kądziołka
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).