fix Go peeing itself

This commit is contained in:
Vegard Berg 2023-09-13 11:22:52 +02:00
parent 77ba4bded8
commit d86bc6e1db
1 changed files with 6 additions and 3 deletions

View File

@ -49,7 +49,7 @@ func PostNewHandler(c echo.Context) error {
}
}
// Determine language from file extension if not set.
if lang == "" {
if lang == "" && name != "" {
lexer := lexers.Match(name)
if lexer != nil {
lang = lexer.Config().Name
@ -61,10 +61,13 @@ func PostNewHandler(c echo.Context) error {
return utils.RenderErrorToast(c, "server-side error occurred")
}
binPartial := pages.BinPartial(createdFile)
setTitle := components.SetTitle(name)
utils.SetHeader(c, "HX-Push", fmt.Sprintf("/b/%s", code))
return utils.RenderComponents(c, http.StatusOK,
pages.BinPartial(createdFile),
components.SetTitle(file.Filename),
binPartial,
setTitle,
)
}