Closed xiaominfc closed 10 years ago
This is not a bug. This behaviour is by design.
+
is an alternative encoding for the space, just like %20
. If you want to actually have a +
in the string you need to encode it properly (%2B
), just like any browser does.
encodeURIComponent("tt+p"); // -> "tt%2Bp"
decodeURIComponent( "tt%2Bp"); // -> "tt+p"
hi,I use express(like version 4.0.0) framework for develop,but meeting a problem.
please tell me about reason and the method for resolve
like url: http://localhost:3000/?name=tt+p;
I get value of req.query.name in a route's method the value of req.query.name should be 'tt+p', but the vlaue is 'tt p', it is lose about symbol ‘+’(plus)
I look the source code
find express(like version 4.0.0) use module 'qs'(node-querystring) about the function to cause my problem function decode(str) { try { return decodeURIComponent(str.replace(/+/g, ' ')); } catch (err) { return str; } }
so why 'str.replace(/+/g, ' ')' in the function?
I change it to 'return decodeURIComponent(str);' that will cause what error happen.
My english is so bad.I beg to be excused.