File tree 2 files changed +34
-13
lines changed
2 files changed +34
-13
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,10 @@ function createLocaleMiddleware (options = {}) {
39
39
if ( typeof options . priority === 'string' ) {
40
40
options . priority = options . priority . split ( / * , * / g) ;
41
41
}
42
- options . priority = options . priority . map ( name => name . toLowerCase ( ) ) ;
42
+
43
+ options . priority = options . priority . map (
44
+ name => name . toLowerCase ( ) in LOOKUP_CREATORS ? name . toLowerCase ( ) : name
45
+ ) ;
43
46
44
47
options . lookups = options . lookups || { } ;
45
48
Original file line number Diff line number Diff line change @@ -110,18 +110,36 @@ describe('with Express', () => {
110
110
. end ( done ) ;
111
111
} ) ;
112
112
113
- it ( 'should parse accept-language header (setting priority in any case)' , done => {
114
- request ( createServer ( {
115
- priority : 'Accept-Language'
116
- } ) )
117
- . get ( '/' )
118
- . set ( 'Accept-Language' , 'es-MX;q=0.8,en-GB;q=0.6' )
119
- . expect ( {
120
- source : 'accept-language' ,
121
- language : 'es' ,
122
- region : 'MX'
123
- } )
124
- . end ( done ) ;
113
+ describe ( 'should handle lookup letter case' , ( ) => {
114
+ it ( 'forcing lower case for default lookups' , done => {
115
+ request ( createServer ( {
116
+ priority : 'Accept-Language'
117
+ } ) )
118
+ . get ( '/' )
119
+ . set ( 'Accept-Language' , 'es-MX;q=0.8,en-GB;q=0.6' )
120
+ . expect ( {
121
+ source : 'accept-language' ,
122
+ language : 'es' ,
123
+ region : 'MX'
124
+ } )
125
+ . end ( done ) ;
126
+ } ) ;
127
+
128
+ it ( 'ignoring for custom lookups' , done => {
129
+ request ( createServer ( {
130
+ priority : 'customLookup' ,
131
+ lookups : {
132
+ customLookup : ( ) => 'fr_FR'
133
+ }
134
+ } ) )
135
+ . get ( '/' )
136
+ . expect ( {
137
+ source : 'customLookup' ,
138
+ language : 'fr' ,
139
+ region : 'FR'
140
+ } )
141
+ . end ( done ) ;
142
+ } ) ;
125
143
} ) ;
126
144
127
145
it ( 'should read cookie' , done => {
You can’t perform that action at this time.
0 commit comments