From 169a49f51b9c9fac75eaf86ba50f1dea067d6a61 Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Wed, 10 Feb 2021 16:43:34 -0500 Subject: [PATCH] internal/source: support example.com domain for testing For golang/go#44214 Change-Id: I70a3cbfa62cc051949437ecba94b8667d12dff3e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290896 Trust: Jonathan Amsterdam Run-TryBot: Jonathan Amsterdam TryBot-Result: kokoro Reviewed-by: Julie Qiu --- internal/source/source.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/source/source.go b/internal/source/source.go index f207478f..772f9b46 100644 --- a/internal/source/source.go +++ b/internal/source/source.go @@ -260,6 +260,13 @@ func ModuleInfo(ctx context.Context, client *Client, modulePath, version string) ctx, span := trace.StartSpan(ctx, "source.ModuleInfo") defer span.End() + // The example.com domain can never be real; it is reserved for testing + // (https://en.wikipedia.org/wiki/Example.com). Treat it as if it used + // GitHub templates. + if strings.HasPrefix(modulePath, "example.com/") { + return NewGitHubInfo("https://"+modulePath, "", version), nil + } + if modulePath == stdlib.ModulePath { return newStdlibInfo(version) }