guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: swh: Handle absolute URLs being returned by the A


From: guix-commits
Subject: branch master updated: swh: Handle absolute URLs being returned by the API.
Date: Sun, 23 Feb 2020 06:29:44 -0500

This is an automated email from the git hooks/post-receive script.

niedzejkob pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new 6a3911b  swh: Handle absolute URLs being returned by the API.
6a3911b is described below

commit 6a3911b88f84eff6b3268b4687caea405f43e39b
Author: Jakub Kądziołka <address@hidden>
AuthorDate: Sun Feb 23 12:06:31 2020 +0100

    swh: Handle absolute URLs being returned by the API.
    
    * 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 | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/guix/swh.scm b/guix/swh.scm
index 8bdf996..ec744fe 100644
--- a/guix/swh.scm
+++ b/guix/swh.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018, 2019, 2020 Ludovic Courtès <address@hidden>
+;;; Copyright © 2020 Jakub Kądziołka <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -126,9 +127,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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]