From a3afb6a148ab25fc47d92ecf1285941edef5204f Mon Sep 17 00:00:00 2001 From: Thomas BrĂ¼derli Date: Fri, 30 Mar 2012 16:15:53 +0000 Subject: Add unicode-safe equivalent of unescape() --- itjs/it.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'itjs/it.js') diff --git a/itjs/it.js b/itjs/it.js index 54fa5c7..b31423e 100644 --- a/itjs/it.js +++ b/itjs/it.js @@ -279,6 +279,24 @@ function it_url_encode(str) return result.replace(/%20/gi, "+").replace(/%2C/gi, ",").replace(/%3B/gi, ";").replace(/%28/gi, "(").replace(/%29/gi, ")"); } +/** + * Unicode-safe equivalent of unescape() + * @param str string URL encoded string to be decoded + */ +function it_url_decode(str) +{ + str = str.replace(/\+/g, '%20'); + + // catch URI malformed errors + try { + if (window.decodeURIComponent) + return decodeURIComponent(str); + } + catch(e) {} + + return unescape(str); +} + /** * Patch PNG transparency for IE 5.5-6 on the given image */ -- cgit v1.2.3