Skip to content

Commit

Permalink
internal/play: fix share registration guard for golang.google.cn
Browse files Browse the repository at this point in the history
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 <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
  • Loading branch information
findleyr committed Jan 16, 2024
1 parent 551a7eb commit d1f7a06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions cmd/golangorg/testdata/godev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ body contains Sorry, but shared playground snippets are not visible in China.
body !contains The Go Playground
body !contains About the Playground

POST https://golang.google.cn/_/share
code == 404

GET https://golang.google.cn/_/share?id=asdfasdf
code == 404

GET https://golang.google.cn/play/p/asdfasdf.go
code == 500
body contains Sorry, but shared playground snippets are not visible in China.
Expand Down
10 changes: 5 additions & 5 deletions internal/play/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ var cacheControlHeader = fmt.Sprintf("public, max-age=%d", int(expires.Seconds()
func RegisterHandlers(mux *http.ServeMux, godevSite, chinaSite *web.Site) {
mux.Handle("/play/", playHandler(godevSite))
mux.Handle("golang.google.cn/play/", playHandler(chinaSite))
for _, host := range []string{"golang.org", "go.dev/_", "golang.google.cn/_"} {
mux.HandleFunc(host+"/compile", compile)
if host != "golang.google.cn" {
mux.HandleFunc(host+"/share", share)
for _, pattern := range []string{"golang.org", "go.dev/_", "golang.google.cn/_"} {
mux.HandleFunc(pattern+"/compile", compile)
if pattern != "golang.google.cn/_" {
mux.HandleFunc(pattern+"/share", share)
}
mux.HandleFunc(host+"/fmt", fmtHandler)
mux.HandleFunc(pattern+"/fmt", fmtHandler)
}
}

Expand Down

0 comments on commit d1f7a06

Please sign in to comment.