This repository was archived by the owner on Dec 31, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,7 +122,6 @@ function getPathCharType (ch: ?string): string {
122122 case 0x2D : // -
123123 return 'ident'
124124
125- case 0x20 : // Space
126125 case 0x09 : // Tab
127126 case 0x0A : // Newline
128127 case 0x0D : // Return
Original file line number Diff line number Diff line change @@ -105,6 +105,13 @@ describe('basic', () => {
105105 it ( 'should be translated' , ( ) => {
106106 assert . strictEqual ( i18n . t ( 'message.format' ) , messages . en . message . format )
107107 } )
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+ } )
108115 } )
109116
110117 describe ( 'array keypath' , ( ) => {
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export default {
2828 circular2 : 'Bar @:message.circular3' ,
2929 circular3 : 'Buz @:message.circular1' ,
3030 linkTwice : '@:message.hello: @:message.hello' ,
31+ 'Hello {0}' : 'Hello {0}' ,
3132 'hyphen-locale' : 'hello hyphen' ,
3233 '1234' : 'Number-based keys are found' ,
3334 '1mixedKey' : 'Mixed keys are not found.' ,
Original file line number Diff line number Diff line change @@ -9,11 +9,28 @@ describe('path', () => {
99 } )
1010 } )
1111
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+
1224 describe ( 'object' , ( ) => {
1325 it ( 'should get path value' , ( ) => {
1426 const val = path . getPathValue ( { a : { b : 1 } } , 'a' )
1527 assert . strictEqual ( val . b , 1 )
1628 } )
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+ } )
1734 } )
1835
1936 describe ( 'number key in object' , ( ) => {
You can’t perform that action at this time.
0 commit comments