]> git.eshelyaron.com Git - emacs.git/commitdiff
Prefer https for other domains than gnu.org in package URL
authorStefan Kangas <stefan@marxist.se>
Sun, 26 Sep 2021 12:29:41 +0000 (14:29 +0200)
committerStefan Kangas <stefan@marxist.se>
Sun, 26 Sep 2021 12:55:19 +0000 (14:55 +0200)
* lisp/emacs-lisp/package.el (describe-package-1): Prefer https for
some other common domains in the package URL.

lisp/emacs-lisp/package.el

index a0bfcbb24fa29d217374dd4f329d5ecf989385f7..94087d172c989e2f155d7064403dceff98a11431 100644 (file)
@@ -2620,12 +2620,17 @@ Helper function for `describe-package'."
                                      (package-desc-name pkg))))
         (insert "\n")))
     (when homepage
-      ;; Prefer https for the homepage of packages on gnu.org.
-      (if (string-match-p "^http://\\(elpa\\|www\\)\\.gnu\\.org/" homepage)
-          (let ((gnu (cdr (assoc "gnu" package-archives))))
-            (and gnu (string-match-p "^https" gnu)
-                 (setq homepage
-                       (replace-regexp-in-string "^http" "https" homepage)))))
+      ;; Prefer https for the homepage of packages on common domains.
+      (when (string-match-p (rx bol "http://" (or "elpa." "www." "git." "")
+                                (or "nongnu.org" "gnu.org" "sr.ht"
+                                    "emacswiki.org" "gitlab.com" "github.com")
+                                "/")
+                            homepage)
+        ;; But only if the user has "https" in `package-archives'.
+        (let ((gnu (cdr (assoc "gnu" package-archives))))
+          (and gnu (string-match-p "^https" gnu)
+               (setq homepage
+                     (replace-regexp-in-string "^http" "https" homepage)))))
       (package--print-help-section "Homepage")
       (help-insert-xref-button homepage 'help-url homepage)
       (insert "\n"))