Skip to content

Commit

Permalink
fix: 国旗被重复添加
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Oct 15, 2019
1 parent 2e005cb commit 80eff22
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/flag.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import EmojiRegex from 'emoji-regex'
import flag from '../misc/flag_cn';

const emojiRegex = EmojiRegex();
const flagMap: {
[name: string]: string; // tslint:disable-line
} = {};
Expand All @@ -13,6 +12,7 @@ Object.keys(flag).forEach(emoji => {
});

export const prependFlag = (str: string): string => {
const emojiRegex = EmojiRegex();
const existingEmoji = emojiRegex.exec(str);

// 如果已经存在 emoji 则不作处理
Expand Down
1 change: 1 addition & 0 deletions test/utils/flag.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ test('addFlag', t => {
t.is(prependFlag('US'), '🇺🇲 US');
t.is(prependFlag('us'), '🇺🇲 us');
t.is(prependFlag('🇺🇲 jp'), '🇺🇲 jp');
t.is(prependFlag('🇯🇵 US'), '🇯🇵 US');
});

0 comments on commit 80eff22

Please sign in to comment.