GNU bug report logs - #39753
[PATCH] guix: swh: Handle absolute URLs being returned by the API.

Previous Next

Package: guix-patches;

Reported by: Jakub Kądziołka <kuba <at> kadziolka.net>

Date: Sun, 23 Feb 2020 11:21:02 UTC

Severity: normal

Tags: patch

Done: Jakub Kądziołka <kuba <at> kadziolka.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39753 in the body.
You can then email your comments to 39753 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#39753; Package guix-patches. (Sun, 23 Feb 2020 11:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jakub Kądziołka <kuba <at> kadziolka.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 23 Feb 2020 11:21:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jakub Kądziołka <kuba <at> kadziolka.net>
To: guix-patches <at> gnu.org
Subject: [PATCH] guix: swh: Handle absolute URLs being returned by the API.
Date: Sun, 23 Feb 2020 12:20:33 +0100
* 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





bug closed, send any further explanations to 39753 <at> debbugs.gnu.org and Jakub Kądziołka <kuba <at> kadziolka.net> Request was from Jakub Kądziołka <kuba <at> kadziolka.net> to control <at> debbugs.gnu.org. (Sun, 23 Feb 2020 11:33:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 23 Mar 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 33 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.