Use replace
instead of replaceAll
for browser compatibility (#222)
Also, moved the `replaced` outside of the find-loop so that we don't re-run it each time.
This commit is contained in:
parent
11d3f88654
commit
60a0d6d31a
1 changed files with 2 additions and 7 deletions
|
@ -98,13 +98,8 @@ export const buildValidSticker = (sticker: string) => `<stkr>${sticker}<stkr>`;
|
|||
export function parseSticker(comment: string) {
|
||||
const matchSticker = comment.match(stickerRegex);
|
||||
const stickerValue = matchSticker && matchSticker[0];
|
||||
const stickerName = stickerValue && stickerValue.replace(/<stkr>/g, '');
|
||||
const commentIsSticker = stickerValue && stickerValue.length === comment.length;
|
||||
|
||||
return (
|
||||
commentIsSticker &&
|
||||
ALL_VALID_STICKERS.find((sticker) => {
|
||||
// $FlowFixMe
|
||||
return sticker.name === stickerValue.replaceAll('<stkr>', '');
|
||||
})
|
||||
);
|
||||
return commentIsSticker && ALL_VALID_STICKERS.find((sticker) => sticker.name === stickerName);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue