From b4e1874a8780260736db0a8c52e8226929440447 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Sat, 20 Apr 2024 11:46:26 +0800 Subject: [PATCH] Fix links in PyPI Simple Repository API page (#30594) (#30612) Backport #30594 by wxiaoguang Thanks to @Zottelchen for looking into problem and proposing the fix. Ref: https://github.com/astral-sh/uv/issues/3017 , https://peps.python.org/pep-0503/ This PR's change is from Zottelchen's work. And I by the way rename the `$p` to `$pd` because `p` is used as "package" in code, while `pd` is used as "package description". ---- Co-authored-by: Zottelchen Co-authored-by: wxiaoguang --- templates/api/packages/pypi/simple.tmpl | 5 +++-- tests/integration/api_packages_pypi_test.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/api/packages/pypi/simple.tmpl b/templates/api/packages/pypi/simple.tmpl index 77cb035600..85aa730c72 100644 --- a/templates/api/packages/pypi/simple.tmpl +++ b/templates/api/packages/pypi/simple.tmpl @@ -4,11 +4,12 @@ Links for {{.PackageDescriptor.Package.Name}} + {{- /* PEP 503 – Simple Repository API: https://peps.python.org/pep-0503/ */ -}}

Links for {{.PackageDescriptor.Package.Name}}

{{range .PackageDescriptors}} - {{$p := .}} + {{$pd := .}} {{range .Files}} - {{.File.Name}}
+ {{.File.Name}}
{{end}} {{end}} diff --git a/tests/integration/api_packages_pypi_test.go b/tests/integration/api_packages_pypi_test.go index a090b31e20..e973f6a52a 100644 --- a/tests/integration/api_packages_pypi_test.go +++ b/tests/integration/api_packages_pypi_test.go @@ -164,7 +164,7 @@ func TestPackagePyPI(t *testing.T) { nodes := htmlDoc.doc.Find("a").Nodes assert.Len(t, nodes, 2) - hrefMatcher := regexp.MustCompile(fmt.Sprintf(`%s/files/%s/%s/test\..+#sha256-%s`, root, regexp.QuoteMeta(packageName), regexp.QuoteMeta(packageVersion), hashSHA256)) + hrefMatcher := regexp.MustCompile(fmt.Sprintf(`%s/files/%s/%s/test\..+#sha256=%s`, root, regexp.QuoteMeta(packageName), regexp.QuoteMeta(packageVersion), hashSHA256)) for _, a := range nodes { for _, att := range a.Attr {