Skip to content

Commit 44197e0

Browse files
committed
fix: 修改錯字 { autoFullHaif => autoFullHalf } 並且保留錯字相容性
1 parent 8877ab0 commit 44197e0

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

packages/regexp-cjk-plugin-extra/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface IZhRegExpPluginOptionsCore {
1212
/**
1313
* 自動配對 半形 全形
1414
*/
15-
autoFullHaif?: boolean;
15+
autoFullHalf?: boolean;
1616
/**
1717
* 配對本地化字元
1818
*/
@@ -50,5 +50,5 @@ export declare function createZhRegExpPlugin(options?: IZhRegExpPluginOptions):
5050
*
5151
* @private
5252
*/
53-
export declare function _coreFn(raw: string, { autoDeburr, autoFullHaif, autoLocale, autoVoice, cacheMap, callback, }: IZhRegExpPluginOptionsRuntime): string[];
53+
export declare function _coreFn(raw: string, { autoDeburr, autoFullHalf, autoLocale, autoVoice, cacheMap, callback, }: IZhRegExpPluginOptionsRuntime): string[];
5454
export default createZhRegExpPlugin;

packages/regexp-cjk-plugin-extra/index.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/regexp-cjk-plugin-extra/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface IZhRegExpPluginOptionsCore
3030
/**
3131
* 自動配對 半形 全形
3232
*/
33-
autoFullHaif?: boolean,
33+
autoFullHalf?: boolean,
3434
/**
3535
* 配對本地化字元
3636
*/
@@ -83,7 +83,10 @@ export function createZhRegExpPlugin(options: IZhRegExpPluginOptions = {}): IOpt
8383
}
8484
}
8585

86-
let { autoDeburr, autoFullHaif, autoLocale, autoVoice } = options;
86+
let { autoDeburr, autoFullHalf, autoLocale, autoVoice } = options;
87+
88+
// @ts-ignore 相容於舊版的錯字
89+
autoFullHalf ??= options.autoFullHaif
8790

8891
let callback = options.callback;
8992

@@ -137,7 +140,7 @@ export function createZhRegExpPlugin(options: IZhRegExpPluginOptions = {}): IOpt
137140

138141
arr = _coreFn(raw2, {
139142
autoDeburr,
140-
autoFullHaif,
143+
autoFullHalf,
141144
autoLocale,
142145
autoVoice,
143146
cacheMap,
@@ -167,7 +170,7 @@ export function createZhRegExpPlugin(options: IZhRegExpPluginOptions = {}): IOpt
167170
{
168171
arr = _coreFn(raw, {
169172
autoDeburr,
170-
autoFullHaif,
173+
autoFullHalf,
171174
autoLocale,
172175
autoVoice,
173176
cacheMap,
@@ -207,7 +210,7 @@ export function createZhRegExpPlugin(options: IZhRegExpPluginOptions = {}): IOpt
207210
*/
208211
export function _coreFn(raw: string, {
209212
autoDeburr,
210-
autoFullHaif,
213+
autoFullHalf,
211214
autoLocale,
212215
autoVoice,
213216
cacheMap,
@@ -229,7 +232,7 @@ export function _coreFn(raw: string, {
229232
ret && arr.push(...ret)
230233
}
231234

232-
if (autoFullHaif)
235+
if (autoFullHalf)
233236
{
234237
let cf = toFullWidth(raw);
235238
let ch = toHalfWidth(raw);

packages/regexp-cjk-plugin-extra/test/demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import createZhRegExpPlugin, { IZhRegExpPluginOptions } from 'regexp-cjk-plugin-
77

88
let options: IZhRegExpPluginOptions = {
99
autoDeburr: true,
10-
autoFullHaif: true,
10+
autoFullHalf: true,
1111
autoLocale: true,
1212
autoVoice: true,
1313
};

packages/regexp-cjk-plugin-extra/test/index.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import createZhRegExpPlugin, { IZhRegExpPluginOptions } from '../index';
33

44
const allOptions: IZhRegExpPluginOptions = Object.freeze({
55
autoDeburr: true,
6-
autoFullHaif: true,
6+
autoFullHalf: true,
77
autoLocale: true,
88
autoVoice: true,
99
});
@@ -16,23 +16,23 @@ describe(`base`, () => {
1616
word: /a/ui,
1717
word_match: `A`,
1818
options: {
19-
autoFullHaif: true,
19+
autoFullHalf: true,
2020
}
2121
},
2222
{
2323
title: `autoFullHaif A / a`,
2424
word: //ui,
2525
word_match: `a`,
2626
options: {
27-
autoFullHaif: true,
27+
autoFullHalf: true,
2828
}
2929
},
3030
{
3131
title: `autoFullHaif <haif width space> / <full width space>>`,
3232
word: / /ui,
3333
word_match: ` `,
3434
options: {
35-
autoFullHaif: true,
35+
autoFullHalf: true,
3636
}
3737
},
3838
{

0 commit comments

Comments
 (0)