File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,11 @@ function SocketRest() {
122
122
123
123
// Fire route function
124
124
if ( resourceMatch ) {
125
+ // Decode params
126
+ for ( let prop in resourceMatch ) {
127
+ resourceMatch [ prop ] = decodeURIComponent ( resourceMatch [ prop ] ) ;
128
+ }
129
+
125
130
// Create request information holder
126
131
var req = {
127
132
query : route . query ,
Original file line number Diff line number Diff line change @@ -143,4 +143,26 @@ describe('#socket-rest', function() {
143
143
} ) ;
144
144
} ) ;
145
145
} ) ;
146
+
147
+ describe ( 'Encoded parameters' , function ( ) {
148
+ var strangeParam = 'some:strange string with _ spaces=" and stuff' ;
149
+
150
+ // Register get route
151
+ socketRest . get ( '/books/:bookName' , function ( req , socket , callback ) {
152
+ expect ( req . params . bookName ) . to . equal ( strangeParam ) ;
153
+
154
+ callback ( ) ;
155
+ } ) ;
156
+
157
+ it ( 'should handle encoded params' , function ( done ) {
158
+ // Connect client and request route
159
+ var client = ioc . connect ( socketURL ) ;
160
+
161
+ client . on ( 'connect' , function ( ) {
162
+ client . emit ( '/books/' + encodeURIComponent ( strangeParam ) + '/get' , function ( ) {
163
+ done ( ) ;
164
+ } ) ;
165
+ } ) ;
166
+ } ) ;
167
+ } ) ;
146
168
} ) ;
You can’t perform that action at this time.
0 commit comments