Ask coding questions

← Back to all posts
Pass a URL in a querystring?
Vandesm14 (1176)

Is it possible for Javascript to send a URL in a querystring/parameter? Like such:
I have seen that this is possible when looking at the url of

But the question comes about how to do this. I've tried URI encoding, which does not work (the request decodes it and tries to do "https:/store.steam", which is not what I want. Is there any form of conversion that I can do to allow a URL to go into a URL querystring?

PS: I cannot use websockets or anything besides a get request

Answered by TheDrone7 (643) [earned 5 cycles]
View Answer
TheDrone7 (643)

Yes it is possible, just encode the URL. If you're using JavaScript, there is the built-in encodeUriComponent function. Here's an example: -
let encoded = encodeUriComponent(""); which will encode the URL to be able to send as a part of the query string in her request. You can later decode it in the same way using the decodeUriComponent function.

Here's how the encoding is done -
You can always use this to build a perfect encoding and decoding function that suits your needs.

Vandesm14 (1176)

@TheDrone7 Yes, but encoding the URL does not work as it is decoded as soon as the get request is sent to my server.

TheDrone7 (643)

@Vandesm14 it might be some other issue then because in my experience that has never happened.