mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 04:26:58 +00:00
refactor
This commit is contained in:
parent
910e097480
commit
0f79db6a4d
1 changed files with 2 additions and 1 deletions
|
@ -65,10 +65,11 @@ const hyphens = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const hyphensCodePoints = hyphens.map(code => `\\u{${code.toString(16).padStart(4, '0')}}`);
|
const hyphensCodePoints = hyphens.map(code => `\\u{${code.toString(16).padStart(4, '0')}}`);
|
||||||
|
const hyphensRegex = new RegExp(`[${hyphensCodePoints.join('')}]`, 'ug');
|
||||||
|
|
||||||
/** ハイフンを統一(ローマ字半角入力時に`ー`と`-`が判定できない問題の調整) */
|
/** ハイフンを統一(ローマ字半角入力時に`ー`と`-`が判定できない問題の調整) */
|
||||||
export function normalizeHyphens(str: string) {
|
export function normalizeHyphens(str: string) {
|
||||||
return str.replace(new RegExp(`[${hyphensCodePoints.join('')}]`, 'ug'), '\u002d');
|
return str.replace(hyphensRegex, '\u002d');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue