Repository: gin-gonic/gin
Pull request #2007 (2019-08-05 17:42:45)

Fixed JSONP format (added semicolon)
According to [wiki](https://en.wikipedia.org/wiki/JSONP), JSONP must have a semicolon at the end of javascript expression.
``` javascript
callback_func({"foo": "bar", "baz": 42}); <-
```

codecov[bot]: # [Codecov](https://codecov.io/gh/gin-gonic/gin/pull/2007?src=pr&el=h1) Report
> Merging [#2007](https://codecov.io/gh/gin-gonic/gin/pull/2007?src=pr&el=desc) into [master](https://codecov.io/gh/gin-gonic/gin/commit/20440b96b9ab70ef45346fb2a71f769586969442?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/gin-gonic/gin/pull/2007/graphs/tree.svg?width=650&token=Qpqxhwery8&height=150&src=pr)](https://codecov.io/gh/gin-gonic/gin/pull/2007?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #2007   +/-   ##
=======================================
  Coverage   98.69%   98.69%           
=======================================
  Files          40       40           
  Lines        2229     2229           
=======================================
  Hits         2200     2200           
  Misses         16       16           
  Partials       13       13
```


| [Impacted Files](https://codecov.io/gh/gin-gonic/gin/pull/2007?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [render/json.go](https://codecov.io/gh/gin-gonic/gin/pull/2007/diff?src=pr&el=tree#diff-cmVuZGVyL2pzb24uZ28=) | `87.34% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/gin-gonic/gin/pull/2007?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/gin-gonic/gin/pull/2007?src=pr&el=footer). Last update [20440b9...26d5f0e](https://codecov.io/gh/gin-gonic/gin/pull/2007?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/render/json.go b/render/json.go
index 2b07cba..70506f7 100644
--- a/render/json.go
+++ b/render/json.go
@@ -138,7 +138,7 @@ func (r JsonpJSON) Render(w http.ResponseWriter) (err error) {
 	if err != nil {
 		return err
 	}
-	_, err = w.Write([]byte(")"))
+	_, err = w.Write([]byte(");"))
 	if err != nil {
 		return err
 	}


Test patch:
diff --git a/context_test.go b/context_test.go
index 439e8ee..f7bb0f5 100644
--- a/context_test.go
+++ b/context_test.go
@@ -676,7 +676,7 @@ func TestContextRenderJSONP(t *testing.T) {
 	c.JSONP(http.StatusCreated, H{"foo": "bar"})
 
 	assert.Equal(t, http.StatusCreated, w.Code)
-	assert.Equal(t, "x({\"foo\":\"bar\"})", w.Body.String())
+	assert.Equal(t, "x({\"foo\":\"bar\"});", w.Body.String())
 	assert.Equal(t, "application/javascript; charset=utf-8", w.Header().Get("Content-Type"))
 }
 
diff --git a/render/render_test.go b/render/render_test.go
index 4cc7197..b27134f 100644
--- a/render/render_test.go
+++ b/render/render_test.go
@@ -146,7 +146,7 @@ func TestRenderJsonpJSON(t *testing.T) {
 	err1 := (JsonpJSON{"x", data}).Render(w1)
 
 	assert.NoError(t, err1)
-	assert.Equal(t, "x({\"foo\":\"bar\"})", w1.Body.String())
+	assert.Equal(t, "x({\"foo\":\"bar\"});", w1.Body.String())
 	assert.Equal(t, "application/javascript; charset=utf-8", w1.Header().Get("Content-Type"))
 
 	w2 := httptest.NewRecorder()
@@ -158,7 +158,7 @@ func TestRenderJsonpJSON(t *testing.T) {
 
 	err2 := (JsonpJSON{"x", datas}).Render(w2)
 	assert.NoError(t, err2)
-	assert.Equal(t, "x([{\"foo\":\"bar\"},{\"bar\":\"foo\"}])", w2.Body.String())
+	assert.Equal(t, "x([{\"foo\":\"bar\"},{\"bar\":\"foo\"}]);", w2.Body.String())
 	assert.Equal(t, "application/javascript; charset=utf-8", w2.Header().Get("Content-Type"))
 }