guix_mirror_bot pushed a commit to branch master
in repository guix.
commit 0311b0e1f8a804db26703ed761d628cded0b542b
Author: Maxim Cournoyer <[email protected]>
AuthorDate: Thu Jun 4 16:01:56 2026 +0900
import: npm-binary: Strip trailing '#readme' in GitHub home page URLs.
* guix/import/npm-binary.scm (npm-package->package-sexp)
<github-hosted?>: New nested procedure.
<sanitize-home-page-url>: Likewise.
<home-page>: Use it.
Change-Id: I886938762c621dc3c81d41993280dd9acb9efb6a
---
guix/import/npm-binary.scm | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/guix/import/npm-binary.scm b/guix/import/npm-binary.scm
index 01079c2814..9c4e0ca57a 100644
--- a/guix/import/npm-binary.scm
+++ b/guix/import/npm-binary.scm
@@ -208,6 +208,17 @@
(($ <versioned-package> name version)
(resolve-package name (string->semver-range version)))))
+ (define (github-hosted? url)
+ (let ((uri (string->uri url)))
+ (string=? "github.com" (uri-host uri))))
+
+ (define (sanitize-home-page-url url)
+ ;; Strip #readme from a github home page URL if any.
+ (if (and (github-hosted? url)
+ (string-suffix? "#readme" url))
+ (string-drop-right url 7)
+ url))
+
(match npm-package
(($ <package-revision>
name version home-page dependencies dev-dependencies
@@ -215,7 +226,7 @@
(let* ((name (npm-name->name name))
(url (dist-tarball dist))
(home-page (if (string? home-page)
- home-page
+ (sanitize-home-page-url home-page)
(string-append %default-page "/" (uri-encode
name))))
(synopsis description)
(resolved-deps (map resolve-spec