From da2daebf48c68a6fd849ea78dc1dd832c7c98931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Fedor?= Date: Tue, 10 Dec 2024 20:27:52 +0100 Subject: [PATCH] Add protocol to custom URLs if it's missing, encode replacement --- src/js/Core/Utils/UrlUtils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/js/Core/Utils/UrlUtils.ts b/src/js/Core/Utils/UrlUtils.ts index 678062171..fb9516a44 100644 --- a/src/js/Core/Utils/UrlUtils.ts +++ b/src/js/Core/Utils/UrlUtils.ts @@ -2,8 +2,12 @@ export default class UrlUtils { public static escapeUserUrl(url: string, replacements: Record): string { + if (!/^[^/]+\/\//.test(url)) { + url = `https://${url}`; + } + for (const [pattern, replacement] of Object.entries(replacements)) { - url = url.replace(`[${pattern}]`, replacement); + url = url.replace(`[${pattern}]`, encodeURIComponent(replacement)); } return (new URL(url)).toString(); }