From 3b706066c914fcde317fb37b6cdbbaca8b0fe8ee Mon Sep 17 00:00:00 2001 From: Bot Dev Date: Wed, 29 Jul 2026 19:06:35 +0200 Subject: [PATCH] dev: fix ALLOWED_HOSTS quoting in content-edit-storage.js --- .../ui/content-edit/content-edit-storage.js | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/public/js/modules/ui/content-edit/content-edit-storage.js b/public/js/modules/ui/content-edit/content-edit-storage.js index 9bcad7c..e2a8db2 100644 --- a/public/js/modules/ui/content-edit/content-edit-storage.js +++ b/public/js/modules/ui/content-edit/content-edit-storage.js @@ -1,28 +1,29 @@ -const API = "/api/content-edits"; - -export function getPagePath() { - const path = window.location.pathname.replace(/^\//, ""); - if (!path || path.endsWith("/")) return "index.html"; - return path; -} - -export async function loadEdits(page = getPagePath()) { - const res = await fetch(`${API}?page=${encodeURIComponent(page)}`); - if (!res.ok) throw new Error("load failed"); - return res.json(); -} - -export async function saveEdits(payload) { - const res = await fetch(`${API}?page=${encodeURIComponent(payload.page)}`, { - method: "PUT", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(payload), - }); - if (!res.ok) throw new Error("save failed"); - return res.json(); -} - -export function isContentEditHost() { - const host = window.location.hostname; - const ALLOWED_HOSTS = [localhost, 127.0.0.1, dev.mamadaevv.site, f2ogw6fzi6trnp7cp43x8wsd.31.129.103.242.sslip.io];\n return ALLOWED_HOSTS.includes(host); -} +const API = "/api/content-edits"; + +export function getPagePath() { + const path = window.location.pathname.replace(/^\//, ""); + if (!path || path.endsWith("/")) return "index.html"; + return path; +} + +export async function loadEdits(page = getPagePath()) { + const res = await fetch(`${API}?page=${encodeURIComponent(page)}`); + if (!res.ok) throw new Error("load failed"); + return res.json(); +} + +export async function saveEdits(payload) { + const res = await fetch(`${API}?page=${encodeURIComponent(payload.page)}`, { + method: "PUT", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(payload), + }); + if (!res.ok) throw new Error("save failed"); + return res.json(); +} + +export function isContentEditHost() { + const host = window.location.hostname; + const ALLOWED_HOSTS = ["localhost", "127.0.0.1", "dev.mamadaevv.site", "f2ogw6fzi6trnp7cp43x8wsd.31.129.103.242.sslip.io"]; + return ALLOWED_HOSTS.includes(host); +}