diff --git a/internal/db/gist.go b/internal/db/gist.go index de12d58..fdd56ab 100644 --- a/internal/db/gist.go +++ b/internal/db/gist.go @@ -377,7 +377,6 @@ func (gist *Gist) UpdatePreviewAndCount() error { gist.Preview = file.Content } - gist.Preview = file.Content gist.PreviewFilename = file.Filename } diff --git a/public/admin.ts b/public/admin.ts index cb7a69e..a044a8d 100644 --- a/public/admin.ts +++ b/public/admin.ts @@ -11,7 +11,9 @@ const setSetting = (key: string, value: string) => { const data = new URLSearchParams(); data.append('key', key); data.append('value', value); - data.append('_csrf', ((document.getElementsByName('_csrf')[0] as HTMLInputElement).value)); + if (document.getElementsByName('_csrf').length !== 0) { + data.append('_csrf', ((document.getElementsByName('_csrf')[0] as HTMLInputElement).value)); + } return fetch('/admin-panel/set-config', { method: 'PUT', credentials: 'same-origin',