0

I have url like below that I am passing in the query string

URL = canada/ontario/shop6

When I access this param that I passed in the query string it discards all the data after first / and gives me just canada as result.

How can I pass the query string with all the / (slashes)?

5
  • 1
    How about passing 'URL=canada/ontario/shop6' to encodeURIComponent? Commented Aug 9, 2020 at 20:40
  • nope it converts / into %2 which I don't want Commented Aug 9, 2020 at 20:45
  • I want to pass / as it is Commented Aug 9, 2020 at 20:48
  • %2F should be equivalent to / in the query string. If it's not, then your server is not compliant with the HTTP spec. Commented Aug 9, 2020 at 20:50
  • @Demon37 Unfornately I think you can't directly pass a slash in a query string. But you can decode %2 back to / by decodeURIComponent. Let me know why you don't want to encode/decode a slash? Commented Aug 9, 2020 at 20:51

1 Answer 1

2

If you absolutely want to pass it through the querystring, you have to encode it with encodeURIComponent and then decode it with decodeURIComponent

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.