fortran
fortran

Reputation: 76077

How to make a request in Node.js with backslashes in the path?

I'm using the request npm module to access a REST service, that needs at some point requires a backslash (\) in part of the path to escape a especial character (it implements a small query DSL).

To my surprise, request is converting those backslashes to forward slashes (/). I've drilled down the problem a little bit more and it seems that it is calling url.parse under the hood and that is the culprit. I can pass a url.parse result with the proper path, but I don't see any option to avoid the back to forward slash conversion.

The ugly option might be to hack the url.parse result myself...

Upvotes: 2

Views: 2441

Answers (1)

admdrew
admdrew

Reputation: 3873

You just need to encode the backslashes (%5C) so that node.js knows they're not part of the URL itself.

Upvotes: 1

Related Questions