Pedro Silva Pedro Silva - 1 year ago 97
Node.js Question

Paramethers with '/' in ExpressJS

I was wondering how to make a GET call passing a param that contains the '/' character. Is it possible?


GET /service/products/GIANAX W/22 cps

Thank you all very much!

Answer Source

Use encodeURIComponent on the piece of the URL that contains the / and use the resulting string as your actual URL.

For example, if you call encodeURIComponent() on "GIANAX W/22 cps" and combine it back with the other part of the URL, you will get:


Note, you can only call encodeURIComponent on one path segment at a time. You can't call it on the whole URL or otherwise it will escape the actual path separators that you want to retain.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download