From a556c584522713d2170003733bc98fd65d1cd80d Mon Sep 17 00:00:00 2001 From: TATSUNO Yasuhiro Date: Sun, 14 Oct 2018 03:24:37 +0900 Subject: [PATCH] :zap: improvement(path): Allow non-ascii chars including numbers. (#436) by @exoego --- src/path.js | 11 +---------- test/unit/fixture/index.js | 12 ++++++++++-- test/unit/issues.test.js | 21 +++++++++++++++++++++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/path.js b/src/path.js index cefcb925b..9337ae432 100644 --- a/src/path.js +++ b/src/path.js @@ -115,7 +115,6 @@ function getPathCharType (ch: ?string): string { case 0x2E: // . case 0x22: // " case 0x27: // ' - case 0x30: // 0 return ch case 0x5F: // _ @@ -134,15 +133,7 @@ function getPathCharType (ch: ?string): string { return 'ws' } - // a-z, A-Z - if ((code >= 0x61 && code <= 0x7A) || (code >= 0x41 && code <= 0x5A)) { - return 'ident' - } - - // 1-9 - if (code >= 0x31 && code <= 0x39) { return 'number' } - - return 'else' + return 'ident' } /** diff --git a/test/unit/fixture/index.js b/test/unit/fixture/index.js index 1271cc96b..986e1de07 100644 --- a/test/unit/fixture/index.js +++ b/test/unit/fixture/index.js @@ -23,8 +23,12 @@ export default { linkTwice: '@:message.hello: @:message.hello', 'hyphen-locale': 'hello hyphen', '1234': 'Number-based keys are found', - '1mixedKey': 'Mixed keys are not found.' + '1mixedKey': 'Mixed keys are not found.', + 'sálvame': 'save me' }, + '0123a': 'Starts with number and contains non-number', + '01234': 'Numeric only', + '日本語': 'Japanese', 'hello world': 'Hello World', 'Hello {0}': 'Hello {0}', 'continue-with-new-account': 'continue with new account', @@ -67,8 +71,12 @@ export default { fallback1: 'これはフォールバック', 'hyphen-locale': 'こんにちは、ハイフン', '1234': '数字ベースのキーは見つかりませんでした。', - '1mixedKey': 'ミックスされたキーは見つかりませんでした。' + '1mixedKey': 'ミックスされたキーは見つかりませんでした。', + 'sálvame': '私を助けて' }, + '01234': '数字のみ', + '12345a': '数字で始まり、数字以外を含む', + '日本語': '日本語', plurals: { car: 'ザ・ワールド | これはフォールバック', implicitPluralCount: 'こっちには来ない | count:{count}, n:{n}', diff --git a/test/unit/issues.test.js b/test/unit/issues.test.js index aa1b8f3af..a3f3b3b9a 100644 --- a/test/unit/issues.test.js +++ b/test/unit/issues.test.js @@ -361,4 +361,25 @@ describe('issues', () => { }) }) }) + + describe('#398', () => { + it('should return true', () => { + assert.strictEqual(vm.$te('0123a'), true) + assert.strictEqual(vm.$te('01234'), true) + assert.strictEqual(vm.$te('message.1234'), true) + }) + }) + + describe('#430', () => { + it('should be translated', () => { + assert.strictEqual( + vm.$t('日本語'), + messages[vm.$i18n.locale]['日本語'] + ) + assert.strictEqual( + vm.$t('message.sálvame'), + messages[vm.$i18n.locale]['message']['sálvame'] + ) + }) + }) })