From 03f3045a8236a88e20d9970f6ffb925dd18e031f Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 10 May 2021 23:49:46 +0200 Subject: [PATCH] Small usability improvement: don't add the trailing '/' to URLs if they weren't typed --- UI/Input/ValidatedTextField.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/UI/Input/ValidatedTextField.ts b/UI/Input/ValidatedTextField.ts index 4f9be38bf0..1881792412 100644 --- a/UI/Input/ValidatedTextField.ts +++ b/UI/Input/ValidatedTextField.ts @@ -145,7 +145,12 @@ export default class ValidatedTextField { for (const dontLike of blacklistedTrackingParams) { url.searchParams.delete(dontLike) } - return url.toString(); + let cleaned = url.toString(); + if(cleaned.endsWith("/") && !str.endsWith("/")){ + // Do not add a trailing '/' if it wasn't typed originally + cleaned = cleaned.substr(0, cleaned.length - 1) + } + return cleaned; } catch (e) { console.error(e) return undefined;