From 07c8bc4af8143b054910abe32563e55501fe61bf Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 7 Apr 2022 12:23:17 +0100 Subject: [PATCH] Fix endless encoding loop with screen URLs --- .../store/screenTemplates/utils/sanitizeUrl.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/builderStore/store/screenTemplates/utils/sanitizeUrl.js b/packages/builder/src/builderStore/store/screenTemplates/utils/sanitizeUrl.js index 16224a45bc..e1c0485258 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/utils/sanitizeUrl.js +++ b/packages/builder/src/builderStore/store/screenTemplates/utils/sanitizeUrl.js @@ -2,9 +2,14 @@ export default function (url) { return url .split("/") .map(part => { - // if parameter, then use as is - if (part.startsWith(":")) return part - return encodeURIComponent(part.replace(/ /g, "-")) + part = decodeURIComponent(part) + + // If parameter, then use as is + if (!part.startsWith(":")) { + part = encodeURIComponent(part) + } + + return part.replace(/ /g, "-") }) .join("/") .toLowerCase()