From d8f9db547a3d3354b747b2aa609ff12017f60edd Mon Sep 17 00:00:00 2001 From: David Roetzel Date: Tue, 17 Sep 2024 16:59:29 +0200 Subject: [PATCH] Merge commit from fork Co-authored-by: Eugen Rochko --- app/javascript/mastodon/reducers/accounts_map.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/javascript/mastodon/reducers/accounts_map.js b/app/javascript/mastodon/reducers/accounts_map.js index 9053dcc9c0..d1229169cc 100644 --- a/app/javascript/mastodon/reducers/accounts_map.js +++ b/app/javascript/mastodon/reducers/accounts_map.js @@ -4,11 +4,10 @@ import { ACCOUNT_LOOKUP_FAIL } from '../actions/accounts'; import { importAccounts } from '../actions/accounts_typed'; import { domain } from '../initial_state'; -export const normalizeForLookup = str => { - str = str.toLowerCase(); - const trailingIndex = str.indexOf(`@${domain.toLowerCase()}`); - return (trailingIndex > 0) ? str.slice(0, trailingIndex) : str; -}; +const pattern = new RegExp(`@${domain}$`, 'gi'); + +export const normalizeForLookup = str => + str.toLowerCase().replace(pattern, ''); const initialState = ImmutableMap();