Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

Commit a556c58

Browse files
TATSUNO Yasuhirokazupon
authored andcommitted
⚡ improvement(path): Allow non-ascii chars including numbers. (#436) by @exoego
1 parent e84f0fb commit a556c58

3 files changed

Lines changed: 32 additions & 12 deletions

File tree

src/path.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ function getPathCharType (ch: ?string): string {
115115
case 0x2E: // .
116116
case 0x22: // "
117117
case 0x27: // '
118-
case 0x30: // 0
119118
return ch
120119

121120
case 0x5F: // _
@@ -134,15 +133,7 @@ function getPathCharType (ch: ?string): string {
134133
return 'ws'
135134
}
136135

137-
// a-z, A-Z
138-
if ((code >= 0x61 && code <= 0x7A) || (code >= 0x41 && code <= 0x5A)) {
139-
return 'ident'
140-
}
141-
142-
// 1-9
143-
if (code >= 0x31 && code <= 0x39) { return 'number' }
144-
145-
return 'else'
136+
return 'ident'
146137
}
147138

148139
/**

test/unit/fixture/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ export default {
2323
linkTwice: '@:message.hello: @:message.hello',
2424
'hyphen-locale': 'hello hyphen',
2525
'1234': 'Number-based keys are found',
26-
'1mixedKey': 'Mixed keys are not found.'
26+
'1mixedKey': 'Mixed keys are not found.',
27+
'sálvame': 'save me'
2728
},
29+
'0123a': 'Starts with number and contains non-number',
30+
'01234': 'Numeric only',
31+
'日本語': 'Japanese',
2832
'hello world': 'Hello World',
2933
'Hello {0}': 'Hello {0}',
3034
'continue-with-new-account': 'continue with new account',
@@ -67,8 +71,12 @@ export default {
6771
fallback1: 'これはフォールバック',
6872
'hyphen-locale': 'こんにちは、ハイフン',
6973
'1234': '数字ベースのキーは見つかりませんでした。',
70-
'1mixedKey': 'ミックスされたキーは見つかりませんでした。'
74+
'1mixedKey': 'ミックスされたキーは見つかりませんでした。',
75+
'sálvame': '私を助けて'
7176
},
77+
'01234': '数字のみ',
78+
'12345a': '数字で始まり、数字以外を含む',
79+
'日本語': '日本語',
7280
plurals: {
7381
car: 'ザ・ワールド | これはフォールバック',
7482
implicitPluralCount: 'こっちには来ない | count:{count}, n:{n}',

test/unit/issues.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,25 @@ describe('issues', () => {
361361
})
362362
})
363363
})
364+
365+
describe('#398', () => {
366+
it('should return true', () => {
367+
assert.strictEqual(vm.$te('0123a'), true)
368+
assert.strictEqual(vm.$te('01234'), true)
369+
assert.strictEqual(vm.$te('message.1234'), true)
370+
})
371+
})
372+
373+
describe('#430', () => {
374+
it('should be translated', () => {
375+
assert.strictEqual(
376+
vm.$t('日本語'),
377+
messages[vm.$i18n.locale]['日本語']
378+
)
379+
assert.strictEqual(
380+
vm.$t('message.sálvame'),
381+
messages[vm.$i18n.locale]['message']['sálvame']
382+
)
383+
})
384+
})
364385
})

0 commit comments

Comments
 (0)