This repository was archived by the owner on Dec 31, 2024. It is now read-only.
File tree 4 files changed +25
-1
lines changed
4 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,6 @@ function getPathCharType (ch: ?string): string {
122
122
case 0x2D : // -
123
123
return 'ident'
124
124
125
- case 0x20 : // Space
126
125
case 0x09 : // Tab
127
126
case 0x0A : // Newline
128
127
case 0x0D : // Return
Original file line number Diff line number Diff line change @@ -105,6 +105,13 @@ describe('basic', () => {
105
105
it ( 'should be translated' , ( ) => {
106
106
assert . strictEqual ( i18n . t ( 'message.format' ) , messages . en . message . format )
107
107
} )
108
+
109
+ it ( 'should be translated if keypath contains spaces' , ( ) => {
110
+ assert . strictEqual (
111
+ i18n . t ( 'message.Hello {0}' , [ 'kazupon' ] ) ,
112
+ 'Hello kazupon'
113
+ )
114
+ } )
108
115
} )
109
116
110
117
describe ( 'array keypath' , ( ) => {
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export default {
28
28
circular2 : 'Bar @:message.circular3' ,
29
29
circular3 : 'Buz @:message.circular1' ,
30
30
linkTwice : '@:message.hello: @:message.hello' ,
31
+ 'Hello {0}' : 'Hello {0}' ,
31
32
'hyphen-locale' : 'hello hyphen' ,
32
33
'1234' : 'Number-based keys are found' ,
33
34
'1mixedKey' : 'Mixed keys are not found.' ,
Original file line number Diff line number Diff line change @@ -9,11 +9,28 @@ describe('path', () => {
9
9
} )
10
10
} )
11
11
12
+ describe ( 'whitespace' , ( ) => {
13
+ it ( 'should get value if it contains space 0x20' , ( ) => {
14
+ const val = path . getPathValue ( { 'a c' : 1 } , 'a c' )
15
+ assert . strictEqual ( val , 1 )
16
+ } )
17
+
18
+ it ( 'should return null if it contains whitespace chars except space 0x20' , ( ) => {
19
+ const val = path . getPathValue ( { 'a\tc' : 1 } , 'a\tc' )
20
+ assert . strictEqual ( val , null )
21
+ } )
22
+ } )
23
+
12
24
describe ( 'object' , ( ) => {
13
25
it ( 'should get path value' , ( ) => {
14
26
const val = path . getPathValue ( { a : { b : 1 } } , 'a' )
15
27
assert . strictEqual ( val . b , 1 )
16
28
} )
29
+
30
+ it ( 'should accept space 0x20 as keypath' , ( ) => {
31
+ const val = path . getPathValue ( { a : { 'b c d' : 1 } } , 'a.b c d' )
32
+ assert . strictEqual ( val , 1 )
33
+ } )
17
34
} )
18
35
19
36
describe ( 'number key in object' , ( ) => {
You can’t perform that action at this time.
0 commit comments