From 494f5b5c07ac0b5584db8f58b9dbda249ed68536 Mon Sep 17 00:00:00 2001 From: Raymonzut <40148684+Raymonzut@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:55:50 +0200 Subject: [PATCH] Fix #5 --- server/routes/api/posts.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/routes/api/posts.js b/server/routes/api/posts.js index 6080231..8b34a49 100644 --- a/server/routes/api/posts.js +++ b/server/routes/api/posts.js @@ -60,7 +60,11 @@ routes.set('/:id', async (req, res) => { routes.set('/urls', async (req, res) => { const re = /(\/api\/)?(.*)\/urls/g const result = [...req.raw.originalUrl.matchAll(re)] - if (!result) notFoundResponse(res) + if (!result) { + notFoundResponse(res) + return + } + const endpoint = result [1] ? result[1][2] : result[0][2] // Assumes https const BASE_URL = 'https://' + req.raw.hostname + endpoint