diff --git a/app/javascript/mastodon/reducers/accounts_map.js b/app/javascript/mastodon/reducers/accounts_map.js
index 9053dcc9c0528b07cbeea57eb96c61e78c5f4faf..d1229169cc3821429e5b346969bea96ccfc68478 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();