Skip to content

Commit

Permalink
x/pkgsite: Trim HTTP or HTTPS Scheme from Source Code links
Browse files Browse the repository at this point in the history
Trimming the URL by creating a new template function which trims the
scheme of the URL

Fixes golang/go#40943
  • Loading branch information
Rahul Wadhwani committed Aug 27, 2020
1 parent d642347 commit 32ada83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions internal/frontend/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})),
Expand Down Expand Up @@ -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",
})),
Expand Down Expand Up @@ -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",
})),
},
Expand All @@ -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",
})),
},
Expand All @@ -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",
})),
},
Expand Down Expand Up @@ -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",
})),
},
Expand All @@ -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",
})),
},
Expand Down
2 changes: 1 addition & 1 deletion internal/testing/sample/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 32ada83

Please sign in to comment.