$node
querystring = require('querystring')
var dict = { 'q': 'what\'s up' };
var url = 'http://google.com/?q=' + querystring.stringify(dict);
url = encodeURIComponent(url);
console.log(url);
The result is this:
"http://google.com/?q=q=what's%20up"
Notice how the single quote is not encoded correctly. Is there something wrong with the node.js module?
it is encoded correctly, if you type the same query into google sear field manually you will get this address:
note that
&q=what's+up&partand
encodeURIComponentis not a Node.js module, but part of standard javascript libraryhttps://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent
manual workaround: