From 9dff67f003122917f634f0b7ad7f07c070a0d4c9 Mon Sep 17 00:00:00 2001 From: Thomas Miceli <27960254+thomiceli@users.noreply.github.com> Date: Fri, 22 Sep 2023 17:31:19 +0200 Subject: [PATCH] Various bug fixes (#105) --- internal/db/gist.go | 1 - public/admin.ts | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) 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',