Skip to content

Commit c185cb8

Browse files
committed
Fix new line literal in embed (#237)
1 parent 1c1e3a8 commit c185cb8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/web/gist.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,9 @@ func gistJs(ctx echo.Context) error {
443443
js := `document.write('<link rel="stylesheet" href="%s">')
444444
document.write('%s')
445445
`
446-
js = fmt.Sprintf(js, cssUrl,
447-
strings.Replace(htmlbuf.String(), "\n", `\n`, -1))
446+
content := strings.Replace(htmlbuf.String(), `\n`, `\\n`, -1)
447+
content = strings.Replace(content, "\n", `\n`, -1)
448+
js = fmt.Sprintf(js, cssUrl, content)
448449
ctx.Response().Header().Set("Content-Type", "application/javascript")
449450
return plainText(ctx, 200, js)
450451
}

0 commit comments

Comments
 (0)