From 20f34e91e25004a94ed196e168496d0a89ebd976 Mon Sep 17 00:00:00 2001 From: 3nprob <3nprob@3nprob> Date: Fri, 8 Oct 2021 02:21:04 +0900 Subject: [PATCH] Fix escaped ' in JSON --- src/fetchers.ts | 4 ++-- src/handlers.ts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fetchers.ts b/src/fetchers.ts index 4a16707..6b97e7d 100644 --- a/src/fetchers.ts +++ b/src/fetchers.ts @@ -74,8 +74,8 @@ export const fetchGallery = async (galleryID: string): Promise => { if (!postDataMatches || postDataMatches.length < 2) { throw new Error('Could not parse gallery data'); } - const postData = JSON.parse(JSON.parse(postDataMatches[1])); - return postData; + const body = postDataMatches[1].replace(/\\'/g, "'"); + return JSON.parse(JSON.parse(body)); }; export const fetchMedia = async (filename: string): Promise> => diff --git a/src/handlers.ts b/src/handlers.ts index 6e8d815..27c80ca 100644 --- a/src/handlers.ts +++ b/src/handlers.ts @@ -33,7 +33,6 @@ export const handleAlbum = async (request: Hapi.Request, h: Hapi.ResponseToolkit pageTitle: CONFIG.page_title, util, }); - }; export const handleUser = (request: Hapi.Request, h: Hapi.ResponseToolkit) => {