node-js-libs / curlrequest

A cURL wrapper
MIT License
184 stars 44 forks source link

Curl request with [brackets] in URL returns error #40

Closed pixelsage closed 8 years ago

pixelsage commented 8 years ago

URL to curl request: https://bibles.org/v2/passages.js?q[]=john+3:1-5&version=eng-ESV

Returns error: Error: URL malformed. The syntax was not correct.

I think I've narrowed the issue to the URL having brackets, since removing the brackets allows the request to run (though brackets are necessary for a proper response).

API: http://bibles.org/pages/api/documentation/passages Note: API Key required to run query.

chriso commented 8 years ago

You could try the globoff curl option:

-g, --globoff This option switches off the "URL globbing parser". When you set this option, you can specify URLs that contain the letters {}[] without having them being interpreted by curl itself. Note that these letters are not normal legal URL contents but they should be encoded according to the URI standard.

curl.request({
  url: 'https://bibles.org/v2/passages.js?q[]=john+3:1-5&version=eng-ESV',
  globoff: true
}, function (err, response) {
  // ...
});
pixelsage commented 8 years ago

That's the solution! Thanks again for your help.