From b1518c6a6f10ee9d41ccc22b0ba012a06e626aa4 Mon Sep 17 00:00:00 2001 From: Sean Liao Date: Mon, 8 Dec 2025 19:46:25 +0000 Subject: internal/licenses: allow overriding links to licenses The HPND license has been retired, but should still be considered valid for use. opensource.org changed the url that hosts the license, and it doesn't appear to follow any specific pattern, so we need to keep an override mapping. Fixes golang/go#76119 Change-Id: I554781021acc599785c8840f404bd01c6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/728260 Reviewed-by: Ethan Lee kokoro-CI: kokoro LUCI-TryBot-Result: Go LUCI Reviewed-by: David Chase --- internal/licenses/licenses.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/licenses/licenses.go b/internal/licenses/licenses.go index 5a1f8d07..2a685967 100644 --- a/internal/licenses/licenses.go +++ b/internal/licenses/licenses.go @@ -191,6 +191,14 @@ var ( "Zlib", } + // licenseURLOverrides provides a mapping from a license identifier to its + // correct URL. This is used for licenses where the URL has changed or does + // not follow the standard pattern. + licenseURLOverrides = map[string]string{ + // HPND is a retired license, and the URL has changed. + "HPND": "https://opensource.org/license/historical-php", + } + // These aren't technically licenses, but they are recognized by // licensecheck and safe to ignore. ignorableLicenseTypes = map[string]bool{ @@ -278,7 +286,9 @@ func AcceptedLicenses() []AcceptedLicenseInfo { var lics []AcceptedLicenseInfo for _, identifier := range standardRedistributableLicenseTypes { var link string - if nonOSILicenses[identifier] { + if override, ok := licenseURLOverrides[identifier]; ok { + link = override + } else if nonOSILicenses[identifier] { link = fmt.Sprintf("https://spdx.org/licenses/%s.html", identifier) } else { link = fmt.Sprintf("https://opensource.org/licenses/%s", identifier) -- cgit v1.3