Skip to content

Commit

Permalink
Fix new line literal in embed (thomiceli#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomiceli committed Apr 2, 2024
1 parent 1c1e3a8 commit c185cb8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/web/gist.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,9 @@ func gistJs(ctx echo.Context) error {
js := `document.write('<link rel="stylesheet" href="%s">')
document.write('%s')
`
js = fmt.Sprintf(js, cssUrl,
strings.Replace(htmlbuf.String(), "\n", `\n`, -1))
content := strings.Replace(htmlbuf.String(), `\n`, `\\n`, -1)
content = strings.Replace(content, "\n", `\n`, -1)
js = fmt.Sprintf(js, cssUrl, content)
ctx.Response().Header().Set("Content-Type", "application/javascript")
return plainText(ctx, 200, js)
}
Expand Down

0 comments on commit c185cb8

Please sign in to comment.