From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:58731) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j5pJo-0007UA-GP for guix-patches@gnu.org; Sun, 23 Feb 2020 06:21:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j5pJn-0004Yd-BG for guix-patches@gnu.org; Sun, 23 Feb 2020 06:21:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44464) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j5pJm-0004YK-GA for guix-patches@gnu.org; Sun, 23 Feb 2020 06:21:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j5pJm-00024e-CR for guix-patches@gnu.org; Sun, 23 Feb 2020 06:21:02 -0500 Subject: [bug#39753] [PATCH] guix: swh: Handle absolute URLs being returned by the API. Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:58648) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j5pIt-0006wV-MN for guix-patches@gnu.org; Sun, 23 Feb 2020 06:20:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j5pIs-00045n-Io for guix-patches@gnu.org; Sun, 23 Feb 2020 06:20:07 -0500 Received: from pat.zlotemysli.pl ([37.59.186.212]:36000) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j5pIs-00043a-8m for guix-patches@gnu.org; Sun, 23 Feb 2020 06:20:06 -0500 From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Date: Sun, 23 Feb 2020 12:20:33 +0100 Message-Id: <20200223112033.16166-1-kuba@kadziolka.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 39753@debbugs.gnu.org * 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