Skip to content

Commit

Permalink
⚡ improvement(path): Allow non-ascii chars including numbers. (#436) by
Browse files Browse the repository at this point in the history
  • Loading branch information
TATSUNO Yasuhiro authored and kazupon committed Oct 13, 2018
1 parent e84f0fb commit a556c58
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
11 changes: 1 addition & 10 deletions src/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ function getPathCharType (ch: ?string): string {
case 0x2E: // .
case 0x22: // "
case 0x27: // '
case 0x30: // 0
return ch

case 0x5F: // _
Expand All @@ -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'
}

/**
Expand Down
12 changes: 10 additions & 2 deletions test/unit/fixture/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -67,8 +71,12 @@ export default {
fallback1: 'これはフォールバック',
'hyphen-locale': 'こんにちは、ハイフン',
'1234': '数字ベースのキーは見つかりませんでした。',
'1mixedKey': 'ミックスされたキーは見つかりませんでした。'
'1mixedKey': 'ミックスされたキーは見つかりませんでした。',
'sálvame': '私を助けて'
},
'01234': '数字のみ',
'12345a': '数字で始まり、数字以外を含む',
'日本語': '日本語',
plurals: {
car: 'ザ・ワールド | これはフォールバック',
implicitPluralCount: 'こっちには来ない | count:{count}, n:{n}',
Expand Down
21 changes: 21 additions & 0 deletions test/unit/issues.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
)
})
})
})

0 comments on commit a556c58

Please sign in to comment.