Search code examples
vbscriptjavascripturl-encoding

How to judge if a URL is already encoded with encodeURI?


I'm trying to do it in VBScript/JScript, to avoid re-encoding.
Should I judge if there is "%" ? Does "%" have other uses in URL?
Thanks.

Edit: Oh, the original encoding function may not be encodeURI.
I'm trying to collect URLs from the browser, and store them after encoding with encodeURI.
But if the URL is already encoded, another encoding will make it wrong.


Solution

  • iterate over the chars in the url and test for characters that aren't allowed in an url.

    if there are any encode it. if there aren't any illegal characters, it doesn't matter