cmd/golangorg: fix blog feed on home page
New jsonp handler was buggy,
and unclear whether redirects are followed.
Change-Id: Ib1e85aa879018cb8e0da664ec47b10dfcda049c5
Reviewed-on: https://go-review.googlesource.com/c/website/+/343410
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Website-Publish: Russ Cox <rsc@golang.org>
diff --git a/_content/index.html b/_content/index.html
index ae08edd..bd93e7f 100644
--- a/_content/index.html
+++ b/_content/index.html
@@ -142,7 +142,7 @@
window.initFuncs.push(function() {
// Load blog feed.
$("<script/>")
- .attr("src", "//blog.golang.org/.json?jsonp=feedLoaded")
+ .attr("src", "https://go.dev/blog/.json?jsonp=feedLoaded")
.appendTo("body");
// Set the video at random.
diff --git a/internal/blog/blog.go b/internal/blog/blog.go
index 9a865a2..1f857f6 100644
--- a/internal/blog/blog.go
+++ b/internal/blog/blog.go
@@ -183,7 +183,8 @@
jsonHandler := func(w http.ResponseWriter, r *http.Request) {
if p := r.FormValue("jsonp"); validJSONPFunc.MatchString(p) {
w.Header().Set("Content-type", "application/javascript; charset=utf-8")
- io.WriteString(w, p)
+ io.WriteString(w, p+"(")
+ defer io.WriteString(w, ")")
} else {
w.Header().Set("Content-type", "application/json; charset=utf-8")
}