From fc439634bb0d7f0c458047314a163778747f80a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Bakondy?= Date: Fri, 15 Aug 2014 13:46:27 +0200 Subject: [PATCH 01/10] Hungarian second level domains Source: http://www.domain.hu/domain/English/szabalyzat/sld.html --- src/SecondLevelDomains.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SecondLevelDomains.js b/src/SecondLevelDomains.js index a4280983..8d8ed887 100644 --- a/src/SecondLevelDomains.js +++ b/src/SecondLevelDomains.js @@ -80,6 +80,7 @@ 'gt':' com edu gob ind mil net org ', 'gu':' com edu gov net org ', 'hk':' com edu gov idv net org ', + 'hu':' 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ', 'id':' ac co go mil net or sch web ', 'il':' ac co gov idf k12 muni net org ', 'in':' ac co edu ernet firm gen gov i ind mil net nic org res ', From cb598f9c8c07bf7690aeabc0ce1a853d22777463 Mon Sep 17 00:00:00 2001 From: Mike Butsko Date: Tue, 19 Aug 2014 20:14:55 -0400 Subject: [PATCH 02/10] Add audio/video src to domAttributes --- src/URI.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/URI.js b/src/URI.js index f13ddeac..dfca68e0 100644 --- a/src/URI.js +++ b/src/URI.js @@ -225,7 +225,9 @@ 'embed': 'src', 'source': 'src', 'track': 'src', - 'input': 'src' // but only if type="image" + 'input': 'src', // but only if type="image" + 'audio': 'src', + 'video': 'src' }; URI.getDomAttribute = function(node) { if (!node || !node.nodeName) { From 87c045854af6f0ed463b534a73e8436f6edccfcc Mon Sep 17 00:00:00 2001 From: Rodney Rehm Date: Wed, 20 Aug 2014 13:43:08 +0200 Subject: [PATCH 03/10] simplify authority range detection --- src/URI.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/URI.js b/src/URI.js index dfca68e0..542a1e8f 100644 --- a/src/URI.js +++ b/src/URI.js @@ -482,11 +482,7 @@ URI.parseUserinfo = function(string, parts) { // extract username:password var firstSlash = string.indexOf('/'); - /*jshint laxbreak: true */ - var pos = firstSlash > -1 - ? string.lastIndexOf('@', firstSlash) - : string.indexOf('@'); - /*jshint laxbreak: false */ + var pos = string.lastIndexOf('@', firstSlash > -1 ? firstSlash : string.length - 1); var t; // authority@ must come before /path From 7ccc328e16a928d1aa4aaa6f2f2b0cee636d5e6d Mon Sep 17 00:00:00 2001 From: Rodney Rehm Date: Wed, 20 Aug 2014 15:16:23 +0200 Subject: [PATCH 04/10] file:// actually may have a host, because we are a non-strict parser, we even allow the full authority - #158 --- src/URI.js | 3 --- test/urls.js | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/URI.js b/src/URI.js index 542a1e8f..daa95c30 100644 --- a/src/URI.js +++ b/src/URI.js @@ -416,9 +416,6 @@ if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) { // : may be within the path parts.protocol = undefined; - } else if (parts.protocol === 'file') { - // the file scheme: does not contain an authority - string = string.substring(pos + 3); } else if (string.substring(pos + 1, pos + 3) === '//') { string = string.substring(pos + 3); diff --git a/test/urls.js b/test/urls.js index 10038e5d..d1432cc6 100644 --- a/test/urls.js +++ b/test/urls.js @@ -1184,14 +1184,14 @@ var urls = [{ } }, { name: 'file:// Windows-Drive-Letter', - url: 'file://C:/WINDOWS/foo.txt', + url: 'file:///C:/WINDOWS/foo.txt', parts: { protocol: 'file', username: null, password: null, hostname: null, port: null, - path: 'C:/WINDOWS/foo.txt', + path: '/C:/WINDOWS/foo.txt', query: null, fragment: null }, @@ -1200,16 +1200,16 @@ var urls = [{ username: '', password: '', port: '', - path: 'C:/WINDOWS/foo.txt', + path: '/C:/WINDOWS/foo.txt', query: '', fragment: '', - resource: 'C:/WINDOWS/foo.txt', + resource: '/C:/WINDOWS/foo.txt', authority: '', userinfo: '', subdomain: '', domain: '', tld: '', - directory: 'C:/WINDOWS', + directory: '/C:/WINDOWS', filename: 'foo.txt', suffix: 'txt', hash: '', From 7b125d21d0e1a6513fa2f4e2325fcabe907f82ae Mon Sep 17 00:00:00 2001 From: Rodney Rehm Date: Wed, 20 Aug 2014 15:27:53 +0200 Subject: [PATCH 05/10] adding tests for file:// from [WikiPedia](http://en.wikipedia.org/wiki/File_URI_scheme#Examples) --- test/urls.js | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/test/urls.js b/test/urls.js index d1432cc6..0677ab9d 100644 --- a/test/urls.js +++ b/test/urls.js @@ -1182,6 +1182,53 @@ var urls = [{ idn: false, punycode: false } + }, { + name: 'file://example.org:123', + url: 'file://example.org:123/foo/bar/baz.html', + parts: { + protocol: 'file', + username: null, + password: null, + hostname: 'example.org', + port: '123', + path: '/foo/bar/baz.html', + query: null, + fragment: null + }, + accessors: { + protocol: 'file', + username: '', + password: '', + port: '123', + path: '/foo/bar/baz.html', + query: '', + fragment: '', + resource: '/foo/bar/baz.html', + authority: 'example.org:123', + userinfo: '', + subdomain: '', + domain: 'example.org', + tld: 'org', + directory: '/foo/bar', + filename: 'baz.html', + suffix: 'html', + hash: '', + search: '', + host: 'example.org:123', + hostname: 'example.org' + }, + is: { + urn: false, + url: true, + relative: false, + name: true, + sld: false, + ip: false, + ip4: false, + ip6: false, + idn: false, + punycode: false + } }, { name: 'file:// Windows-Drive-Letter', url: 'file:///C:/WINDOWS/foo.txt', @@ -1229,6 +1276,100 @@ var urls = [{ idn: false, punycode: false } + }, { + name: 'file://example.org/ Windows-Drive-Letter', + url: 'file://example.org/C:/WINDOWS/foo.txt', + parts: { + protocol: 'file', + username: null, + password: null, + hostname: 'example.org', + port: null, + path: '/C:/WINDOWS/foo.txt', + query: null, + fragment: null + }, + accessors: { + protocol: 'file', + username: '', + password: '', + port: '', + path: '/C:/WINDOWS/foo.txt', + query: '', + fragment: '', + resource: '/C:/WINDOWS/foo.txt', + authority: 'example.org', + userinfo: '', + subdomain: '', + domain: 'example.org', + tld: 'org', + directory: '/C:/WINDOWS', + filename: 'foo.txt', + suffix: 'txt', + hash: '', + search: '', + host: 'example.org', + hostname: 'example.org' + }, + is: { + urn: false, + url: true, + relative: false, + name: true, + sld: false, + ip: false, + ip4: false, + ip6: false, + idn: false, + punycode: false + } + }, { + name: 'file://localhost/ Windows-Drive-Letter with pipe', + url: 'file://localhost/C|/WINDOWS/foo.txt', + parts: { + protocol: 'file', + username: null, + password: null, + hostname: 'localhost', + port: null, + path: '/C|/WINDOWS/foo.txt', + query: null, + fragment: null + }, + accessors: { + protocol: 'file', + username: '', + password: '', + port: '', + path: '/C|/WINDOWS/foo.txt', + query: '', + fragment: '', + resource: '/C|/WINDOWS/foo.txt', + authority: 'localhost', + userinfo: '', + subdomain: '', + domain: 'localhost', + tld: 'localhost', + directory: '/C|/WINDOWS', + filename: 'foo.txt', + suffix: 'txt', + hash: '', + search: '', + host: 'localhost', + hostname: 'localhost' + }, + is: { + urn: false, + url: true, + relative: false, + name: true, + sld: false, + ip: false, + ip4: false, + ip6: false, + idn: false, + punycode: false + } }, { name: 'Path containing @', url: 'http://www.example.org/@foobar', From f6b686940bbeaa24c6aa81099cc3a177720136fd Mon Sep 17 00:00:00 2001 From: Rodney Rehm Date: Wed, 20 Aug 2014 16:18:28 +0200 Subject: [PATCH 06/10] updating readme (stuff got merged into gh-pages, meh) --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 76a75a4b..4787d2cf 100644 --- a/README.md +++ b/README.md @@ -172,11 +172,20 @@ How other environments do things [Discussion on Hacker News](https://news.ycombinator.com/item?id=3398837) +### Forks / Code-borrow ### + +* [node-dom-urls](https://github.com/passy/node-dom-urls) passy's partial implementation of the W3C URL Spec Draft for Node +* [urlutils](https://github.com/cofounders/urlutils) cofounders' `window.URL` constructor for Node ### Alternatives ### If you don't like URI.js, you may like one of the following libraries. (If yours is not listed, drop me a line…) +#### Polyfill #### + +* [DOM-URL-Polyfill](https://github.com/arv/DOM-URL-Polyfill/) arv's polyfill of the [DOM URL spec](https://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#interface-urlutils) for browsers +* [inexorabletash](https://github.com/inexorabletash/polyfill/#whatwg-url-api) inexorabletash's [WHATWG URL API](http://url.spec.whatwg.org/) + #### URL Manipulation #### * [The simple URL Mutation "Hack"](http://jsfiddle.net/rodneyrehm/KkGUJ/) ([jsPerf comparison](http://jsperf.com/idl-attributes-vs-uri-js)) @@ -229,6 +238,12 @@ URI.js is published under the [MIT license](http://www.opensource.org/licenses/m ## Changelog ## +### master branch ### + +* adding Hungarian second level domains - ([Issue #159](https://github.com/medialize/URI.js/issues/159)) +* adding `readable()) + "</a>"; + + escapeHtml(uri.readable()) + "</a>"; });

As of URI.js 1.12.0 withinString accepts the following parameters:

From 1d6c2a1c34ae8bd67ac59b72acb662d142a35adb Mon Sep 17 00:00:00 2001 From: Rodney Rehm Date: Fri, 29 Aug 2014 20:52:48 +0200 Subject: [PATCH 09/10] do not raise error on malformed URI - closing #163 --- README.md | 1 + src/URI.js | 14 +++++++++++--- test/test.js | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de226c28..f2518f98 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,7 @@ URI.js is published under the [MIT license](http://www.opensource.org/licenses/m * adding Hungarian second level domains - ([Issue #159](https://github.com/medialize/URI.js/issues/159)) * adding `