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.I might try decoding it and comparing the result to the original URL. If it changed or got shorter in length your original URL was probably already encoded.
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
精彩评论