diff --git a/docs.html b/docs.html index b950bff3..0deeaa2c 100644 --- a/docs.html +++ b/docs.html @@ -116,6 +116,8 @@

URI.js

  • URI.commonPath()
  • URI.withinString()
  • +
  • URI.iso8859()
  • +
  • URI.unicode()
  • @@ -757,6 +759,20 @@

    URI.withinString()

    }); +

    URI.iso8859()

    +

    URI.iso8859() tells URI.js to use the older escape/unescape methods, for backwards compatibility with older platforms.

    +
    URI.iso8859();
    +
    +var uri = new URI("http://example.org/foo/æ.html");
    +// http://example.org/foo/%E6.html
    + +

    URI.unicode()

    +

    URI.unicode() restores the default unicode-encoded URLs.

    +
    URI.unicode();
    +
    +var uri = new URI("http://example.org/foo/æ.html");
    +// http://example.org/foo/%C3%A6.html
    + - \ No newline at end of file + diff --git a/src/URI.js b/src/URI.js index a1be1e3a..0853e881 100644 --- a/src/URI.js +++ b/src/URI.js @@ -65,8 +65,18 @@ var URI = function(url, base) { } return this; - }, - p = URI.prototype; + }; +var p = URI.prototype; + +URI.iso8859 = function() { + URI.encode = escape; + URI.decode = unescape; +} + +URI.unicode = function() { + URI.encode = encodeURIComponent; + URI.decode = decodeURIComponent; +} // static properties URI.idn_expression = /[^a-z0-9\.-]/i; @@ -122,10 +132,10 @@ URI.characters = { } }; URI.encodeQuery = function(string) { - return encodeURIComponent(string + "").replace(/%20/g, '+'); + return URI.encode(string + "").replace(/%20/g, '+'); }; URI.decodeQuery = function(string) { - return decodeURIComponent((string + "").replace(/\+/g, '%20')); + return URI.decode((string + "").replace(/\+/g, '%20')); }; URI.recodePath = function(string) { var segments = (string + "").split('/'); @@ -1260,4 +1270,4 @@ p.equals = function(uri) { window.URI = URI; -})(); \ No newline at end of file +})();