Leveton/node-parse-api — pull request #16 by gasi (2014-11-04 23:46:47+00:00)
Title: Override `querystring.escape` only locally

First of all, thanks for all your great work on this Node.js Parse API client library.

This fixes a huge, but subtle bug that broke all query string encoding in our project (https://mix.fiftythree.com/). I am not blaming you specifically as you used the API as designed and documented and probably not realizing its side-effects.

In my opinion, Node’s global `querystring.escape` is just poor API design. Since Node modules are cached in memory, overwriting `querystring.escape` will overwrite it for every other client of that module which can lead to subtle, hard to find bugs. In my case, HTML emails using `querystring.stringify` to escape query string parameters started being truncated due to unescaped `&` once I added `node-parse-api` as a dependency.

Workaround: Overwrite `querystring.escape`, use `querystring.stringify`, and then restore `querystring.escape` to original implementation.

FYI, I filed a bug against Node.js core for this: https://github.com/joyent/node/issues/8672