mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Use replace instead of replace all so that we are compatible with v78 (#18080)
* Use replace instead of replace all so that we are compatible with v78 * Add unit tests
This commit is contained in:
parent
642ce91b70
commit
3ad6cf15ae
@ -563,5 +563,5 @@ export const sanitizeString = (value) => {
|
||||
return value;
|
||||
}
|
||||
const regex = /\u202E/giu;
|
||||
return value.replaceAll(regex, '\\u202E');
|
||||
return value.replace(regex, '\\u202E');
|
||||
};
|
||||
|
@ -883,4 +883,28 @@ describe('util', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('sanitizeString', () => {
|
||||
it('should return the passed value, unchanged, if it is falsy', () => {
|
||||
expect(util.sanitizeString('')).toStrictEqual('');
|
||||
});
|
||||
|
||||
it('should return the passed value, unchanged, if it is not a string', () => {
|
||||
expect(util.sanitizeString(true)).toStrictEqual(true);
|
||||
});
|
||||
|
||||
it('should return a truthy string that oes not match the sanitizeString regex, unchanged', () => {
|
||||
expect(
|
||||
util.sanitizeString('The Quick Brown Fox Jumps Over The Lazy Dog'),
|
||||
).toStrictEqual('The Quick Brown Fox Jumps Over The Lazy Dog');
|
||||
});
|
||||
|
||||
it('should return a string that matches sanitizeString regex with the matched characters replaced', () => {
|
||||
expect(
|
||||
util.sanitizeString(
|
||||
'The Quick Brown \u202EFox Jumps Over The Lazy Dog',
|
||||
),
|
||||
).toStrictEqual('The Quick Brown \\u202EFox Jumps Over The Lazy Dog');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user