From 7a345ce6c72007d672f537546a5a37b817d164dd Mon Sep 17 00:00:00 2001 From: Chaphasilor Date: Sun, 1 Aug 2021 14:00:40 +0200 Subject: [PATCH 1/2] more fixes --- src/components/SearchField.vue | 4 ++-- src/store/index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/SearchField.vue b/src/components/SearchField.vue index 1ab87eb..97f73f6 100644 --- a/src/components/SearchField.vue +++ b/src/components/SearchField.vue @@ -288,8 +288,8 @@
Date: Mon, 2 Aug 2021 22:01:45 +0200 Subject: [PATCH 2/2] fix lamba function URI encoding issues --- public/netlify-functions/checkLinkAlive.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/public/netlify-functions/checkLinkAlive.js b/public/netlify-functions/checkLinkAlive.js index 7a59c89..a6ce1b6 100644 --- a/public/netlify-functions/checkLinkAlive.js +++ b/public/netlify-functions/checkLinkAlive.js @@ -24,9 +24,20 @@ const fetchTimeout = (url, ms, options = {}) => { return promise.finally(() => clearTimeout(timeout)); }; +function encodeUriOnce(url, useURIComponent = false) { + + let decoder = useURIComponent ? decodeURIComponent : decodeURI + while(url !== decoder(url)) { + url = decoder(url); + } + + return encodeURI(url); + +} + function resolveLink(url) { - let resolvedUrl = url; + let resolvedUrl = encodeUriOnce(url); let resolvedHeaders = {}; if (url.includes(`driveindex.ga/`)) { @@ -48,7 +59,7 @@ function checkLink(urlData) { return new Promise((resolve) => { const startTime = performance.now() - urlData.url = encodeURI(urlData.url); + urlData.url = encodeUriOnce(urlData.url); fetchTimeout(urlData.url, REQUEST_TIMEOUT, { method: `HEAD`,