Skip to content

Commit d1f7a06

Browse files
committed
internal/play: fix share registration guard for golang.google.cn
CL 366056 added support for multiple play backends, but did not update the pattern matching for golang.google.cn accordingly. Change-Id: Ie992f86bb6879bb283db5a23870602ea1266d9ab Reviewed-on: https://go-review.googlesource.com/c/website/+/556095 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Robert Findley <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 551a7eb commit d1f7a06

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

cmd/golangorg/testdata/godev.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ body contains Sorry, but shared playground snippets are not visible in China.
4949
body !contains The Go Playground
5050
body !contains About the Playground
5151

52+
POST https://golang.google.cn/_/share
53+
code == 404
54+
55+
GET https://golang.google.cn/_/share?id=asdfasdf
56+
code == 404
57+
5258
GET https://golang.google.cn/play/p/asdfasdf.go
5359
code == 500
5460
body contains Sorry, but shared playground snippets are not visible in China.

internal/play/proxy.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ var cacheControlHeader = fmt.Sprintf("public, max-age=%d", int(expires.Seconds()
4646
func RegisterHandlers(mux *http.ServeMux, godevSite, chinaSite *web.Site) {
4747
mux.Handle("/play/", playHandler(godevSite))
4848
mux.Handle("golang.google.cn/play/", playHandler(chinaSite))
49-
for _, host := range []string{"golang.org", "go.dev/_", "golang.google.cn/_"} {
50-
mux.HandleFunc(host+"/compile", compile)
51-
if host != "golang.google.cn" {
52-
mux.HandleFunc(host+"/share", share)
49+
for _, pattern := range []string{"golang.org", "go.dev/_", "golang.google.cn/_"} {
50+
mux.HandleFunc(pattern+"/compile", compile)
51+
if pattern != "golang.google.cn/_" {
52+
mux.HandleFunc(pattern+"/share", share)
5353
}
54-
mux.HandleFunc(host+"/fmt", fmtHandler)
54+
mux.HandleFunc(pattern+"/fmt", fmtHandler)
5555
}
5656
}
5757

0 commit comments

Comments
 (0)