iriscouch / browser-request

Browser library compatible with Node.js request package
Apache License 2.0
360 stars 102 forks source link

Fix requesting a parsed URL object (node.js 'request' compatibility) #44

Open deathcap opened 9 years ago

deathcap commented 9 years ago

The Node 'request' module allows options.uri to be a parsed object from the 'url' module. In this case, the href property is set to the original URL. Check for this property to restore compatibility with browser-request/request.

e.g., this code works in node:

require('request')({uri: require('url').parse('http://npmjs.org/')}, function() {})

and now works with a browserified browser-request. Includes test case