From 93aa2c546f2b312eaf55d387901f80a744133e2d Mon Sep 17 00:00:00 2001 From: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com> Date: Wed, 3 May 2023 18:22:15 +0700 Subject: [PATCH] fix: prevent source duplication --- src/components/settings/sources.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/settings/sources.tsx b/src/components/settings/sources.tsx index 2440a35..9742f6a 100644 --- a/src/components/settings/sources.tsx +++ b/src/components/settings/sources.tsx @@ -204,7 +204,9 @@ class SourcesTab extends React.Component { addSource = (event: React.FormEvent) => { event.preventDefault() - let trimmed = this.state.newUrl.trim() + + // Remove whitespace and trailing slash + const trimmed = this.state.newUrl.trim().replace(/\/$/, '') if (urlTest(trimmed)) this.props.addSource(trimmed) }