Permalink
Browse files

Added IDN (RFC 5890) support.

  • Loading branch information...
garycourt committed Jun 4, 2012
1 parent d5c30bf commit 36f912c39adbf13b4d5ad21a3f9f4b4897a4b2bf
Showing with 581 additions and 29 deletions.
  1. +8 −4 README.md
  2. +1 −1 bin/build.sh
  3. +28 −19 dist/uri.min.js
  4. +13 −1 src/externs.js
  5. +489 −0 src/punycode.js
  6. +3 −1 src/schemes/http.js
  7. +35 −0 src/uri.js
  8. +1 −0 tests/test-src.html
  9. +3 −3 tests/tests.js
View
@@ -1,7 +1,7 @@
# URI.js
URI.js is an [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt) compliant, scheme extendable URI parsing/validating/resolving library for all JavaScript environments (browsers, Node.js, etc).
-It is also compliant with the IRI ([RFC 3987](http://www.ietf.org/rfc/rfc3987.txt)) specification.
+It is also compliant with the IRI ([RFC 3987](http://www.ietf.org/rfc/rfc3987.txt)) and IDNA ([RFC 5890](http://www.ietf.org/rfc/rfc5890.txt)) specifications.
## Loading
@@ -40,7 +40,7 @@ To load in a CommonJS (Node.js) environment, simply use:
### Normalizing
- URI.normalize("HTTP://ABC.com/%7Esmith/home.html") === "http://abc.com/~smith/home.html"
+ URI.normalize("HTTP://ABC.com:80/%7Esmith/home.html") === "http://abc.com/~smith/home.html"
### Comparison
@@ -49,9 +49,9 @@ To load in a CommonJS (Node.js) environment, simply use:
### IRI Support
//convert IRI to URI
- URI.serialize(URI.parse("uri://example.org/rosé", {iri:true})) === "uri://example.org/ros%E9"
+ URI.serialize(URI.parse("http://examplé.org/rosé", {iri:true})) === "http://xn--exampl-gva.org/ros%C3%A9"
//convert URI to IRI
- URI.serialize(URI.parse("uri://example.org/ros%E9"), {iri:true}) === "uri://example.org/rosé"
+ URI.serialize(URI.parse("http://xn--exampl-gva.org/ros%C3%A9"), {iri:true}) === "http://examplé.org/rosé"
### Options
@@ -76,6 +76,10 @@ All of the above functions can accept an additional options argument that is an
* `iri` (boolean, false)
If set to `true`, the library will unescape non-ASCII characters as per [RFC 3987](http://www.ietf.org/rfc/rfc3987.txt).
+
+* `domainHost` (boolean, false)
+
+ If set to `true`, the library will treat the `host` component as a domain name, and convert IDNs (International Domain Names) as per [RFC 5891](http://www.ietf.org/rfc/rfc5891.txt).
## Scheme Extendable
View
@@ -3,7 +3,7 @@
ROOT_DIR="../"
SRC_DIR=${ROOT_DIR}"src/"
DIST_DIR=${ROOT_DIR}"dist/"
-ALL_LIST=( ${SRC_DIR}"uri.js" ${SRC_DIR}"schemes/http.js" ${SRC_DIR}"schemes/urn.js" )
+ALL_LIST=( ${SRC_DIR}"punycode.js" ${SRC_DIR}"uri.js" ${SRC_DIR}"schemes/http.js" ${SRC_DIR}"schemes/urn.js" )
ALL_FILE=${DIST_DIR}"uri.min.js"
EXTERNS_FILE=${SRC_DIR}"externs.js"
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -84,7 +84,13 @@ Options.prototype = {
* @type boolean
*/
- iri : false
+ iri : false,
+
+ /**
+ * @type boolean
+ */
+
+ domainHost : false
};
/**
@@ -175,6 +181,12 @@ SchemeHandler.prototype.absolutePath;
SchemeHandler.prototype.iri;
+/**
+ * @type boolean
+ */
+
+SchemeHandler.prototype.domainHost;
+
/**
* @param {URIComponents} components
* @param {Options} options
Oops, something went wrong.

0 comments on commit 36f912c

Please sign in to comment.