From 7c829d9ebb7ec483c5956b13cd8c96909800184c Mon Sep 17 00:00:00 2001 From: InfiniteStash <117855276+InfiniteStash@users.noreply.github.com> Date: Fri, 12 Jun 2026 13:07:16 +0200 Subject: [PATCH] Trim whitespace from URL input --- frontend/src/components/urlInput/urlInput.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/urlInput/urlInput.tsx b/frontend/src/components/urlInput/urlInput.tsx index d5b1d5d3e..ef14dc727 100644 --- a/frontend/src/components/urlInput/urlInput.tsx +++ b/frontend/src/components/urlInput/urlInput.tsx @@ -56,10 +56,11 @@ const URLInput: FC = ({ lens, type, errors }) => { ); const handleAdd = () => { - if (!newURL || !selectedSite) return; - const cleanedURL = cleanURL(selectedSite?.regex, newURL); + const trimmedURL = newURL.trim(); + if (!trimmedURL || !selectedSite) return; + const cleanedURL = cleanURL(selectedSite?.regex, trimmedURL); - const url = cleanedURL ?? newURL; + const url = cleanedURL ?? trimmedURL; if (!urls.some((u) => u.url === url)) append({ url, @@ -72,9 +73,12 @@ const URLInput: FC = ({ lens, type, errors }) => { setNewURL(""); }; - const handleInput = (url: string) => { + const handleInput = (rawURL: string) => { if (!inputRef.current || !selectRef.current) return; + const url = rawURL.trim(); + if (url !== rawURL) inputRef.current.value = url; + const site = sites.find((s) => s.regex && new RegExp(s.regex).test(url)); if (site && selectedSite?.id !== site.id) {