From 32ada83702894ef47819fe9298df88e449769324 Mon Sep 17 00:00:00 2001 From: Rahul Wadhwani Date: Fri, 28 Aug 2020 00:03:47 +0100 Subject: [PATCH] x/pkgsite: Trim HTTP or HTTPS Scheme from Source Code links Trimming the URL by creating a new template function which trims the scheme of the URL Fixes golang/go#40943 --- internal/frontend/server_test.go | 16 ++++++++-------- internal/testing/sample/sample.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/frontend/server_test.go b/internal/frontend/server_test.go index 3cbe016ea..94fbfcd22 100644 --- a/internal/frontend/server_test.go +++ b/internal/frontend/server_test.go @@ -467,8 +467,8 @@ func serverTestCases() []serverTestCase { pagecheck.OverviewDetails(&pagecheck.Overview{ ModuleLink: "/mod/" + sample.ModulePath + "@v1.0.0", ModuleLinkText: pkgV100.ModulePath, - RepoURL: "https://" + sample.ModulePath, - PackageURL: "https://" + sample.ModulePath + "/tree/v1.0.0/foo", + RepoURL: sample.ModulePath, + PackageURL: sample.ModulePath + "/tree/v1.0.0/foo", ReadmeContent: "readme", ReadmeSource: sample.ModulePath + "@v1.0.0/README.md", })), @@ -605,7 +605,7 @@ func serverTestCases() []serverTestCase { pagecheck.OverviewDetails(&pagecheck.Overview{ ModuleLink: "/mod/" + sample.ModulePath, ModuleLinkText: dir.ModulePath, - RepoURL: "https://" + sample.ModulePath, + RepoURL: sample.ModulePath, ReadmeContent: "readme", ReadmeSource: sample.ModulePath + "@v1.0.0/README.md", })), @@ -644,7 +644,7 @@ func serverTestCases() []serverTestCase { ModuleLink: "/std@go1.13", ModuleLinkText: "Standard Library", ReadmeContent: "readme", - RepoURL: "https://" + sample.ModulePath, // wrong, but hard to change + RepoURL: sample.ModulePath, // wrong, but hard to change ReadmeSource: "go.googlesource.com/go/+/refs/tags/go1.13/README.md", })), }, @@ -668,7 +668,7 @@ func serverTestCases() []serverTestCase { ModuleLink: "/mod/" + sample.ModulePath, ModuleLinkText: sample.ModulePath, ReadmeContent: "readme", - RepoURL: "https://" + sample.ModulePath, + RepoURL: sample.ModulePath, ReadmeSource: sample.ModulePath + "@v1.0.0/README.md", })), }, @@ -684,7 +684,7 @@ func serverTestCases() []serverTestCase { ModuleLink: "/mod/" + sample.ModulePath, ModuleLinkText: sample.ModulePath, ReadmeContent: "readme", - RepoURL: "https://" + sample.ModulePath, + RepoURL: sample.ModulePath, ReadmeSource: sample.ModulePath + "@v1.0.0/README.md", })), }, @@ -721,7 +721,7 @@ func serverTestCases() []serverTestCase { ModuleLink: fmt.Sprintf("/mod/%s@%s", sample.ModulePath, sample.VersionString), ModuleLinkText: sample.ModulePath, ReadmeContent: "readme", - RepoURL: "https://" + sample.ModulePath, + RepoURL: sample.ModulePath, ReadmeSource: sample.ModulePath + "@v1.0.0/README.md", })), }, @@ -735,7 +735,7 @@ func serverTestCases() []serverTestCase { ModuleLink: fmt.Sprintf("/mod/%s@%s", sample.ModulePath, pseudoVersion), ModuleLinkText: sample.ModulePath, ReadmeContent: "readme", - RepoURL: "https://" + sample.ModulePath, + RepoURL: sample.ModulePath, ReadmeSource: sample.ModulePath + "@" + pseudoVersion + "/README.md", })), }, diff --git a/internal/testing/sample/sample.go b/internal/testing/sample/sample.go index ccffa6700..a4cc58731 100644 --- a/internal/testing/sample/sample.go +++ b/internal/testing/sample/sample.go @@ -28,7 +28,7 @@ import ( // These sample values can be used to construct test cases. var ( ModulePath = "github.com/valid/module_name" - RepositoryURL = "https://github.com/valid/module_name" + RepositoryURL = "github.com/valid/module_name" VersionString = "v1.0.0" CommitTime = NowTruncated() LicenseMetadata = []*licenses.Metadata{