Squashed 'thirdparty/URI.js/' content from commit b77c167

git-subtree-dir: thirdparty/URI.js
git-subtree-split: b77c167bc201575956ad409333ff032e504b8044
This commit is contained in:
Florian Dold 2016-10-10 03:47:49 +02:00
commit d519415433
76 changed files with 15279 additions and 0 deletions

9
.editorconfig Normal file
View File

@ -0,0 +1,9 @@
root = true
[**]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.DS_Store
node_modules

31
.jshintrc Normal file
View File

@ -0,0 +1,31 @@
{
"node": true,
"browser": false,
"esnext": false,
"bitwise": false,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"expr": true,
"globals": {
"describe": false,
"it": false,
"before": false,
"beforeEach": false,
"after": false,
"afterEach": false,
"define": false
}
}

332
CHANGELOG.md Normal file
View File

@ -0,0 +1,332 @@
# URI.js - Changelog #
The release notes tracked in this document are also made available on the [releases page](https://github.com/medialize/URI.js/releases)
### 1.18.2 (September 25th 2016) ###
* fixing [`URI.withinString()`](http://medialize.github.io/URI.js/docs.html#static-withinString) to allow callback to return `undefined` or `string` - [Issue #303](https://github.com/medialize/URI.js/issues/303)
* fixing [`.absoluteTo()`](http://medialize.github.io/URI.js/docs.html#absoluteto) to properly resolve relative paths for fragment-only URLs
### 1.18.1 (May 29th 2016) ###
* fixing UMD wrapper of `jquery.URI.js` - [Issue #295](https://github.com/medialize/URI.js/issues/295)
### 1.18.0 (April 30th 2016) ###
* adding [`URI.joinPaths()`](http://medialize.github.io/URI.js/docs.html#static-joinPaths) to compose paths from directory tokens - [Issue #285](https://github.com/medialize/URI.js/issues/285)
* fixing [`URITemplate()`](http://medialize.github.io/URI.js/uri-template.html) to allow `.` in variable names - [PR #287](https://github.com/medialize/URI.js/pull/287)
* fixing [`URITemplate()`](http://medialize.github.io/URI.js/uri-template.html) to reject invalid literals - [PR #289](https://github.com/medialize/URI.js/pull/289)
* fixing [`URITemplate()`](http://medialize.github.io/URI.js/uri-template.html) to reject prefix modifier on composite values - [PR #290](https://github.com/medialize/URI.js/pull/290)
* fixing [`URI.buildUserinfo()`](http://medialize.github.io/URI.js/docs.html#static-buildUserinfo) to properly serialize password-only values - [PR #293](https://github.com/medialize/URI.js/pull/293)
### 1.17.1 (February 25th 2016) ###
* fixing [`.normalizePath()`](http://medialize.github.io/URI.js/docs.html#normalize-path) to properly handle percent-encoded dot segments and leading dots in basename - [Issue #264](https://github.com/medialize/URI.js/issues/264), by [JordanMilne](https://github.com/JordanMilne)
* fixing [`.hasQuery()`](http://medialize.github.io/URI.js/docs.html#search-has) to accept `RegExp` for name argument - [Issue #274](https://github.com/medialize/URI.js/issues/274), [Issue #277](https://github.com/medialize/URI.js/issues/277) by [mbrodala](https://github.com/mbrodala)
### 1.17.0 (November 13th 2015) ###
* fixing [`URI.removeQuery()`](http://medialize.github.io/URI.js/docs.html#search-remove) to cast values to string before matching - [Issue #250](https://github.com/medialize/URI.js/pull/250), [Issue #252](https://github.com/medialize/URI.js/pull/252), by [ryanelian](https://github.com/ryanelian) and [Siltaar](https://github.com/Siltaar)
* fixing [`.segment()`](http://medialize.github.io/URI.js/docs.html#accessors-segment) to allow appending an empty element - [Issue #236](https://github.com/medialize/URI.js/issues/236), [Issue #253](https://github.com/medialize/URI.js/pull/253), by [orlando](https://github.com/orlando)
* adding [`.origin()`](http://medialize.github.io/URI.js/docs.html#accessors-origin) to get protocol and authority, counter-part to `.resource()` - [Issue #210](https://github.com/medialize/URI.js/issues/210), [Issue #263](https://github.com/medialize/URI.js/pull/263), by [justinmchase](https://github.com/justinmchase)
### 1.16.1 (September 19th 2015) ###
Package Management Cleanup - no changes to source code!
* renaming package to "urijs", was "URIjs" (because npm decided to go lower-case at some point and maintaining capitals in your package name poses all sorts of stupid issues)
* removing [jam](http://jamjs.org/), [spm](http://spmjs.org/), `component.json` and `URI.jquery.json` as nobody cared that URI.js was stuck on 1.14 for a year
### 1.16.0 (July 24th 2015) ###
* **SECURITY** fixing [`URI.parseHost()`](http://medialize.github.io/URI.js/docs.html#static-parseHost) to rewrite `\` to `/` as Node and Browsers do - [Issue #233](https://github.com/medialize/URI.js/pull/233)
* fixing [`.host()`](http://medialize.github.io/URI.js/docs.html#accessors-host) and [`.authority()`](http://medialize.github.io/URI.js/docs.html#accessors-authority) to raise an error if they contain a path segment (extending [Issue #233](https://github.com/medialize/URI.js/pull/233))
### 1.15.2 (July 2nd 2015) ###
* fixing [`URI.parseQuery()`](http://medialize.github.io/URI.js/docs.html#static-parseQuery) to accept `?foo&foo=bar` - [Issue #220](https://github.com/medialize/URI.js/issues/220)
* fixing [`.segmentCoded()`](http://medialize.github.io/URI.js/docs.html#accessors-segmentCoded) to encode (instead of decode) array input - [Issue #223](https://github.com/medialize/URI.js/issues/223)
* fixing [`.normalizePath()`](http://medialize.github.io/URI.js/docs.html#normalize-path) to properly resolve `/foo/..` to `/` - [Issue #224](https://github.com/medialize/URI.js/issues/224)
* fixing [`.relativeTo()`](http://medialize.github.io/URI.js/docs.html#relativeto) to resolve `/foo/` and `/foo/bar` to `./` instead of empty string - [Issue #226](https://github.com/medialize/URI.js/issues/226)
* fixing `bower.json`'s `"main": "src/URI.js"` - [Issue #227](https://github.com/medialize/URI.js/issues/227)
### 1.15.1 (April 5th 2015) ###
* fixing `URI()` to match behavior of `new URI()` (caused by [#196](https://github.com/medialize/URI.js/issues/196)) - [Issue #205](https://github.com/medialize/URI.js/issues/205)
* fixing [`URI.removeQuery()`](http://medialize.github.io/URI.js/docs.html#search-remove) to accept RegExp for name and value arguments - ([Issue #204](https://github.com/medialize/URI.js/issues/204), [peterwillis](https://github.com/peterwillis))
### 1.15.0 (April 1st 2015 - no joke, promise!) ###
* fixing `URI(undefined)` to throw TypeError - ([Issue #189](https://github.com/medialize/URI.js/issues/189), [Issue #196](https://github.com/medialize/URI.js/issues/196), [eakron](https://github.com/eakron)) - *tiny backward-compatibility-break*
* fixing [`.absoluteTo()`](http://medialize.github.io/URI.js/docs.html#absoluteto) - ([Issue #200](https://github.com/medialize/URI.js/issues/200), [giltayar](https://github.com/giltayar))
* fixing [`.pathname()`](http://medialize.github.io/URI.js/docs.html#accessors-pathname) to properly en/decode URN paths - ([Issue #201](https://github.com/medialize/URI.js/pull/201), [mlefoster](https://github.com/mlefoster))
* fixing URI normalization to properly handle URN paths based on [RFC 2141](https://www.ietf.org/rfc/rfc2141.txt) syntax - ([Issue #201](https://github.com/medialize/URI.js/pull/201), [mlefoster](https://github.com/mlefoster))
* fixing [`.normalize()`](http://medialize.github.io/URI.js/docs.html#normalize) and [`.normalizePath()`](http://medialize.github.io/URI.js/docs.html#normalize-path) to properly normalize URN paths
* adding `URI.encodeUrnPathSegment()`
* adding `URI.decodeUrnPathSegment()`
* adding `URI.decodeUrnPath()`
* adding `URI.recodeUrnPath()`
### 1.14.2 (February 25th 2015) ###
* fixing inclusion of LICENSE in packages - ([Issue #174](https://github.com/medialize/URI.js/issues/174))
* fixing [`URI.parseHost()`](http://medialize.github.io/URI.js/docs.html#static-parseHost) to not interpret colon in path as IPv6 hostname - ([Issue #190](https://github.com/medialize/URI.js/issues/190))
* adding meta data for [SPM](http://www.spmjs.io/) package manager - ([Issue #176](https://github.com/medialize/URI.js/issues/176))
* adding license meta to `bower.json`
### 1.14.1 (October 1st 2014) ###
* fixing handling of String instances (not string primitives) - ([Issue #146](https://github.com/medialize/URI.js/issues/146))
* fixing Firefox [`.watch()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch) interfering with `.parseQuery()` - ([Issue #169](https://github.com/medialize/URI.js/issues/169))
* fixing [`addQuery()`](http://medialize.github.io/URI.js/docs.html#search-add) to not throw error on null value - ([Issue #171](https://github.com/medialize/URI.js/issues/171))
### 1.14.0 (September 8th 2014) ###
* adding Hungarian second level domains - ([Issue #159](https://github.com/medialize/URI.js/issues/159))
* adding `<audio src="…">` and `<video src="…">` to supported DOM attributes - ([Issue #160](https://github.com/medialize/URI.js/issues/160)), ([Issue #161](https://github.com/medialize/URI.js/issues/161))
* fixing `file://hostname/path` parsing - ([Issue #158](https://github.com/medialize/URI.js/issues/158))
* fixing `.decodePathSegment()` to not throw malformed URI error - ([Issue #163](https://github.com/medialize/URI.js/issues/163))
### 1.13.2 (May 29th 2014) ###
* changes to package management manifests only
### 1.13.1 (April 16th 2014) ###
* fixing IPv6 normalization (bad variable name) - ([Issue #145](https://github.com/medialize/URI.js/issues/145))
* adding grunt and jshint
* changing code style to 2 spaces indentation, single quote strings
* applying `'use strict';` everywhere
* fixing jshint warnings
### 1.13.0 (April 15th 2014) ###
* fixing [`URI.parseHost()`](http://medialize.github.io/URI.js/docs.html#static-parseHost) and [`URI.buildHost()`](http://medialize.github.io/URI.js/docs.html#static-buildHost) to properly parse and build the IPv6 examples given in [RFC2732 Format for Literal IPv6 Addresses in URL's](http://tools.ietf.org/html/rfc2732#section-2) - ([Issue #144](https://github.com/medialize/URI.js/issues/144))
* adding performance improvements to SecondLevelDomain - ([PR #122](https://github.com/medialize/URI.js/pull/122), [gorhill](https://github.com/gorhill))
### 1.12.1 (March 8th 2014) ###
* fixing [`.encodeQuery()`](http://medialize.github.io/URI.js/docs.html#static-encodeQuery) and [`.decodeQuery()`](http://medialize.github.io/URI.js/docs.html#static-decodeQuery) to respect [`URI.escapeQuerySpace`](http://medialize.github.io/URI.js/docs.html#setting-escapeQuerySpace) - ([Issue #137](https://github.com/medialize/URI.js/issues/137))
* fixing fragment plugins to return URI for simpler loading - ([Issue #139](https://github.com/medialize/URI.js/issues/139))
### 1.12.0 (January 23rd 2014) ###
* fixing [`.absoluteTo()`](http://medialize.github.io/URI.js/docs.html#absoluteto) to comply with [RFC3986 Reference Resolution Examples](http://tools.ietf.org/html/rfc3986#section-5.4) - ([Issue #113](https://github.com/medialize/URI.js/issues/113))
* fixing [`.normalizePath()`](http://medialize.github.io/URI.js/docs.html#normalize-path) to maintain leading parent references (`../`) for relative paths, while removing them for absolute paths - ([Issue #133](https://github.com/medialize/URI.js/issues/133))
* fixing `URI.protocol_expression` to properly accept `.` in compliance with [RFC 3986 - Scheme](http://tools.ietf.org/html/rfc3986#section-3.1) - ([Issue #132](https://github.com/medialize/URI.js/issues/132))
* fixing [`URI.withinString()`](http://medialize.github.io/URI.js/docs.html#static-withinString) to not use backtracking prone regular expression `URI.find_uri_expression` anymore - ([Issue #131](https://github.com/medialize/URI.js/issues/131))
* fixing [`URI.withinString()`](http://medialize.github.io/URI.js/docs.html#static-withinString) to accept options `ignore` and `ignoreHtml` to allow better control over which detected URLs get handled - ([Issue #117](https://github.com/medialize/URI.js/issues/117))
* fixing [`URI.withinString()`](http://medialize.github.io/URI.js/docs.html#static-withinString) to accept option `start` to specify the RegExp used for finding the beginning of an URL (defaults to `/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi`) - ([Issue #115](https://github.com/medialize/URI.js/issues/115))
### 1.11.2 (August 14th 2013) ###
* fixing regression for Node.js introduced by `fixing unsafe eval by using UMD's root` - ([Issue #107](https://github.com/medialize/URI.js/issues/107))
* fixing parser to accept malformed userinfo (non-encoded email address) - ([Issue #108](https://github.com/medialize/URI.js/issues/108))
### 1.11.1 (August 13th 2013) ###
* fixing inconsistent [`.relativeTo()`](http://medialize.github.io/URI.js/docs.html#relativeto) results caused by inconsistent URI component handling - ([Issue #103](https://github.com/medialize/URI.js/issues/103))
* fixing unsafe eval by using UMD's root - ([Issue #105](https://github.com/medialize/URI.js/issues/105))
* fixing [`.segment()`](http://medialize.github.io/URI.js/docs.html#accessors-segment) to allow appending an empty element - ([Issue #106](https://github.com/medialize/URI.js/issues/106))
* fixing [`.segment()`](http://medialize.github.io/URI.js/docs.html#accessors-segment) to collapse empty elements in array notation
### 1.11.0 (August 6th 2013) ###
* adding [`.segmentCoded()`](http://medialize.github.io/URI.js/docs.html#accessors-segmentCoded) to provide en/decoding interface to `.segment()` - ([Issue #79](https://github.com/medialize/URI.js/issues/79))
* optimize [`.relativeTo()`](http://medialize.github.io/URI.js/docs.html#relativeto) results - ([Issue #78](https://github.com/medialize/URI.js/issues/78), [Issue #95](https://github.com/medialize/URI.js/issues/95))
* removing obsolete code fragments from `URI.parse()` and `relativeTo()` - ([Issue #100](https://github.com/medialize/URI.js/issues/100))
* adding setting [`URI.escapeQuerySpace`](http://medialize.github.io/URI.js/docs.html#setting-escapeQuerySpace) to control if query string should escape spaces using `+` or `%20` - ([Issue #74](https://github.com/medialize/URI.js/issues/74))
* updating [Punycode.js](https://github.com/bestiejs/punycode.js/) to version 1.2.3
* fixing internal `strictEncodeURIComponent()` to work in Firefox 3.6 - ([Issue #91](https://github.com/medialize/URI.js/issues/91))
* fixing [`.normalizePath()`](http://medialize.github.io/URI.js/docs.html#normalize-path) to properly resolve `/.` and `/.//` to `/` - ([Issue #97](https://github.com/medialize/URI.js/issues/97))
* fixing [`.path()`](http://medialize.github.io/URI.js/docs.html#accessors-pathname) to return empty string if there is no path - ([Issue #82](https://github.com/medialize/URI.js/issues/82))
* fixing crashing of `URI.decodeQuery()` on malformed input - now returns original undecoded data - ([Issue #87](https://github.com/medialize/URI.js/issues/87), [Issue #92](https://github.com/medialize/URI.js/issues/92))
* fixing build tool - ([Issue #83](https://github.com/medialize/URI.js/issues/83))
* fixing for-loop to make closure compiler happy - ([Issue #93](https://github.com/medialize/URI.js/issues/93))
* adding [`URI.noConflict()`](http://medialize.github.io/URI.js/docs.html#static-noConflict) - ([Issue #84](https://github.com/medialize/URI.js/issue/84))
* fixing whitespace in code - ([Issue #84](https://github.com/medialize/URI.js/issue/84))
* fixing [`.readable()`](http://medialize.github.io/URI.js/docs.html#readable) to decode the hash value as well - ([Issue #90](https://github.com/medialize/URI.js/issue/90))
* prevent `jquery.URI.js` from temporarily using `window.location` as the `href` of an empty attribute of a DOM element - ([Issue #94](https://github.com/medialize/URI.js/issues/94))
* fixing internal `getType()` for IE8 with undefined value - ([Issue #96](https://github.com/medialize/URI.js/issues/96))
* adding DOM elements to [URI constructor](http://medialize.github.io/URI.js/docs.html#constructor) - ([Issue #77](https://github.com/medialize/URI.js/issues/77)):
* [`<a href="...">`](http://www.w3.org/html/wg/drafts/html/master/text-level-semantics.html#the-a-element)
* [`<blockquote cite="...">`](http://www.w3.org/html/wg/drafts/html/master/grouping-content.html#the-blockquote-element)
* [`<link href="...">`](http://www.w3.org/html/wg/drafts/html/master/document-metadata.html#the-link-element)
* [`<base href="...">`](http://www.w3.org/html/wg/drafts/html/master/document-metadata.html#the-base-element)
* [`<script src="...">`](http://www.w3.org/html/wg/drafts/html/master/scripting-1.html#script)
* [`<form action="...">`](http://www.w3.org/html/wg/drafts/html/master/forms.html#the-form-element)
* [`<input type="image" src="...">`](http://www.w3.org/html/wg/drafts/html/master/forms.html#the-input-element)
* [`<img src="...">`](http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#the-img-element)
* [`<area href="...">`](http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#the-area-element)
* [`<iframe src="...">`](http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#the-iframe-element)
* [`<embed src="...">`](http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#the-embed-element)
* [`<source src="...">`](http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#the-source-element)
* [`<track src="...">`](http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#the-track-element)
* optimize `jquery.URI.js` to use new DOM element infrastructure
### 1.10.2 (April 15th 2013) ###
* fixing [`relativeTo()`](http://medialize.github.io/URI.js/docs.html#relativeto) - ([Issue #75](https://github.com/medialize/URI.js/issues/75))
* fixing [`normalizePath()`](http://medialize.github.io/URI.js/docs.html#normalize-path) to not prepend `./` to relative paths - ([Issue #76](https://github.com/medialize/URI.js/issues/76))
### 1.10.1 (April 2nd 2013) ###
* adding [`absoluteTo()`](http://medialize.github.io/URI.js/docs.html#absoluteto) to properly resolve relative scheme - ([Issue #71](https://github.com/medialize/URI.js/issues/73))
### 1.10.0 (March 16th 2013) ###
* adding [`hasQuery()`](http://medialize.github.io/URI.js/docs.html#search-has) - ([Issue #71](https://github.com/medialize/URI.js/issues/71))
* fixing URI property detection to return 'src' if none was detected (`jquery.URI.js`) - ([Issue #69](https://github.com/medialize/URI.js/issues/69))
### 1.9.1 (February 12th 2013) ###
* fixing IE9 compatibility with location import: `URI(location)`
* fixing string character access for IE7 - ([Issue #67](https://github.com/medialize/URI.js/issues/67)), ([Issue #68](https://github.com/medialize/URI.js/issues/68))
### 1.9.0 (February 11th 2013) ###
* adding [`.setQuery()`](http://medialize.github.io/URI.js/docs.html#search-set) - ([Issue #64](https://github.com/medialize/URI.js/issues/64))
* adding callback argument to [`.query()`](http://medialize.github.io/URI.js/docs.html#accessors-search)
* adding jQuery 1.9.1 to the test suite
### 1.8.3 (January 9th 2013) ###
* fixing [UglifyJS2](https://github.com/mishoo/UglifyJS2) compression - ([Issue #60](https://github.com/medialize/URI.js/issues/60), [fidian](https://github.com/fidian))
### 1.8.2 (December 27th 2012) ###
* adding `.fragmentPrefix()` to configure prefix of fragmentURI and fragmentQuery extensions - ([Issue #55](https://github.com/medialize/URI.js/issues/55))
* adding docs for [`.toString()`, `.valueOf()`](http://medialize.github.io/URI.js/docs.html#toString) and [`.href()`](http://medialize.github.io/URI.js/docs.html#href) - ([Issue #56](https://github.com/medialize/URI.js/issues/56))
* fixing [`.relativeTo()`](http://medialize.github.io/URI.js/docs.html#relativeto) for descendants - ([Issue #57](https://github.com/medialize/URI.js/issues/57))
### 1.8.1 (November 15th 2012) ###
* fixing build() to properly omit empty query and fragment ([Issue #53](https://github.com/medialize/URI.js/issues/53))
### 1.8.0 (November 13th 2012) ###
* adding [`.resource()`](http://medialize.github.io/URI.js/docs.html#accessors-resource) as compound of [path, query, fragment]
* adding jQuery 1.8.x compatibility for jQuery.URI.js (remaining backwards compatibility!)
* adding default ports for gopher, ws, wss
* adding [`.duplicateQueryParameters()`](http://medialize.github.io/URI.js/docs.html#setting-duplicateQueryParameters) to control if `key=value` duplicates have to be preserved or reduced ([Issue #51](https://github.com/medialize/URI.js/issues/51))
* updating [Punycode.js](https://github.com/bestiejs/punycode.js/) to version 1.1.1
* improving AMD/Node using [UMD returnExports](https://github.com/umdjs/umd/blob/master/returnExports.js) - ([Issue #44](https://github.com/medialize/URI.js/issues/44), [Issue #47](https://github.com/medialize/URI.js/issues/47))
* fixing `.addQuery("empty")` to properly add `?empty` - ([Issue #46](https://github.com/medialize/URI.js/issues/46))
* fixing parsing of badly formatted userinfo `http://username:pass:word@hostname`
* fixing parsing of Windows-Drive-Letter paths `file://C:/WINDOWS/foo.txt`
* fixing `URI(location)` to properly parse the URL - ([Issue #52](https://github.com/medialize/URI.js/issues/52))
* fixing type error for fragment abuse demos - ([Issue #50](https://github.com/medialize/URI.js/issues/50))
* adding documentation for various [encode/decode functions](http://medialize.github.io/URI.js/docs.html#encoding-decoding)
* adding some pointers on possible problems with URLs to [About URIs](http://medialize.github.io/URI.js/about-uris.html)
* adding tests for fragment abuse and splitting tests into separate scopes
* adding meta-data for [Jam](http://jamjs.org/) and [Bower](http://twitter.github.com/bower/)
Note: QUnit seems to be having some difficulties on IE8. While the jQuery-plugin tests fail, the plugin itself works. We're still trying to figure out what's making QUnit "lose its config state".
### 1.7.4 (October 21st 2012) ###
* fixing parsing of `/wiki/Help:IPA` - ([Issue #49](https://github.com/medialize/URI.js/issues/49))
### 1.7.3 (October 11th 2012) ###
* fixing `strictEncodeURIComponent()` to properly encode `*` to `%2A`
* fixing IE9's incorrect report of `img.href` being available - ([Issue #48](https://github.com/medialize/URI.js/issues/48))
### 1.7.2 (August 28th 2012) ###
* fixing SLD detection in [`.tld()`](http://medialize.github.io/URI.js/docs.html#accessors-tld) - `foot.se` would detect `t.se` - ([Issue #42](https://github.com/medialize/URI.js/issues/42))
* fixing [`.absoluteTo()`](http://medialize.github.io/URI.js/docs.html#absoluteto) to comply with [RFC 3986 Section 5.2.2](http://tools.ietf.org/html/rfc3986#section-5.2.2) - ([Issue #41](https://github.com/medialize/URI.js/issues/41))
* fixing `location` not being available in non-browser environments like node.js ([Issue #45](https://github.com/medialize/URI.js/issues/45) [grimen](https://github.com/grimen))
### 1.7.1 (August 14th 2012) ###
* fixing [`.segment()`](http://medialize.github.io/URI.js/docs.html#accessors-segment)'s append operation - ([Issue #39](https://github.com/medialize/URI.js/issues/39))
### 1.7.0 (August 11th 2012) ###
* fixing URI() constructor passing of `base` - ([Issue #33](https://github.com/medialize/URI.js/issues/33) [LarryBattle](https://github.com/LarryBattle))
* adding [`.segment()`](http://medialize.github.io/URI.js/docs.html#accessors-segment) accessor - ([Issue #34](https://github.com/medialize/URI.js/issues/34))
* upgrading `URI.encode()` to strict URI encoding according to RFC3986
* adding `URI.encodeReserved()` to exclude reserved characters (according to RFC3986) from being encoded
* adding [URI Template (RFC 6570)](http://tools.ietf.org/html/rfc6570) support with [`URITemplate()`](http://medialize.github.io/URI.js/uri-template.html)
### 1.6.3 (June 24th 2012) ###
* fixing [`.absoluteTo()`](http://medialize.github.io/URI.js/docs.html#absoluteto) to join two relative paths properly - ([Issue #29](https://github.com/medialize/URI.js/issues/29))
* adding [`.clone()`](http://medialize.github.io/URI.js/docs.html#clone) to copy an URI instance
### 1.6.2 (June 23rd 2012) ###
* [`.directory()`](http://medialize.github.io/URI.js/docs.html#accessors-directory) now returns empty string if there is no directory
* fixing [`.absoluteTo()`](http://medialize.github.io/URI.js/docs.html#absoluteto) to join two relative paths properly - ([Issue #29](https://github.com/medialize/URI.js/issues/29))
### 1.6.1 (May 19th 2012) ###
* fixing TypeError on [`.domain()`](http://medialize.github.io/URI.js/docs.html#accessors-domain) with dot-less hostnames - ([Issue #27](https://github.com/medialize/URI.js/issues/27))
### 1.6.0 (March 19th 2012) ###
* adding [URN](http://tools.ietf.org/html/rfc3986#section-3) (`javascript:`, `mailto:`, ...) support
* adding [`.scheme()`](http://medialize.github.io/URI.js/docs.html#accessors-protocol) as alias of [`.protocol()`](http://medialize.github.io/URI.js/docs.html#accessors-protocol)
* adding [`.userinfo()`](http://medialize.github.io/URI.js/docs.html#accessors-userinfo) to comply with terminology of [RFC 3986](http://tools.ietf.org/html/rfc3986#section-3.2.1)
* adding [jQuery Plugin](http://medialize.github.io/URI.js/jquery-uri-plugin.html) `src/jquery.URI.js`
* fixing relative scheme URLs - ([Issue #19](https://github.com/medialize/URI.js/issues/19) [byroot](https://github.com/byroot))
### 1.5.0 (February 19th 2012) ###
* adding Second Level Domain (SLD) Support - ([Issue #17](https://github.com/medialize/URI.js/issues/17))
### 1.4.3 (January 28th 2012) ###
* fixing global scope leakage - ([Issue #15](https://github.com/medialize/URI.js/issues/15) [mark-rushakoff](https://github.com/mark-rushakoff))
### 1.4.2 (January 25th 2012) ###
* improving CommonJS compatibility - ([Issue #14](https://github.com/medialize/URI.js/issues/14) [FGRibreau](https://github.com/FGRibreau))
### 1.4.1 (January 21st 2012) ###
* adding CommonJS compatibility - ([Issue #11](https://github.com/medialize/URI.js/issues/11), [Evangenieur](https://github.com/Evangenieur))
### 1.4.0 (January 12th 2012) ###
* adding [`URI.iso8859()`](http://medialize.github.io/URI.js/docs.html#static-iso8859) and [`URI.unicode()`](http://medialize.github.io/URI.js/docs.html#static-unicode) to switch base charsets - ([Issue #10](https://github.com/medialize/URI.js/issues/10), [mortenn](https://github.com/))
* adding [`.iso8859()`](http://medialize.github.io/URI.js/docs.html#iso8859) and [`.unicode()`](http://medialize.github.io/URI.js/docs.html#unicode) to convert an URI's escape encoding
### 1.3.1 (January 3rd 2011) ###
* updating Punycode.js to version 0.3.0
* adding edge-case tests ("jim")
* fixing edge-cases in .protocol(), .port(), .subdomain(), .domain(), .tld(), .filename()
* fixing parsing of hostname in [`.hostname()`](http://medialize.github.io/URI.js/docs.html#accessors-hostname)
### 1.3.0 (December 30th 2011) ###
* adding [`.subdomain()`](http://medialize.github.io/URI.js/docs.html#accessors-subdomain) convenience accessor
* improving internal deferred build handling
* fixing thrown Error for `URI("http://example.org").query(true)` - ([Issue #6](https://github.com/medialize/URI.js/issues/6))
* adding examples for extending URI.js for [fragment abuse](http://medialize.github.io/URI.js/docs.html#fragment-abuse), see src/URI.fragmentQuery.js and src/URI.fragmentURI.js - ([Issue #2](https://github.com/medialize/URI.js/issues/2))
### 1.2.0 (December 29th 2011) ###
* adding [`.equals()`](http://medialize.github.io/URI.js/docs.html#equals) for URL comparison
* fixing encoding/decoding for [`.pathname()`](http://medialize.github.io/URI.js/docs.html#accessors-pathname), [`.directory()`](http://medialize.github.io/URI.js/docs.html#accessors-directory), [`.filename()`](http://medialize.github.io/URI.js/docs.html#accessors-filename) and [`.suffix()`](http://medialize.github.io/URI.js/docs.html#accessors-suffix) according to [RFC 3986 3.3](http://tools.ietf.org/html/rfc3986#section-3.3)
* fixing escape spaces in query strings with `+` according to [application/x-www-form-urlencoded](http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type)
* fixing to allow [`URI.buildQuery()`](http://medialize.github.io/URI.js/docs.html#static-buildQuery) to build duplicate key=value combinations
* fixing [`URI(string, string)`](http://medialize.github.io/URI.js/docs.html#constructor) constructor to conform with the [specification](http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#constructor)
* adding [`.readable()`](http://medialize.github.io/URI.js/docs.html#readable) for humanly readable representation of encoded URIs
* fixing bug where @ in pathname would be parsed as part of the authority
### 1.1.0 (December 28th 2011) ###
* adding [`URI.withinString()`](http://medialize.github.io/URI.js/docs.html#static-withinString)
* adding [`.normalizeProtocol()`](http://medialize.github.io/URI.js/docs.html#normalize-protocol) to lowercase protocols
* fixing [`.normalizeHostname()`](http://medialize.github.io/URI.js/docs.html#normalize-host) to lowercase hostnames
* fixing String.substr() to be replaced by String.substring() - ([Issue #1](https://github.com/medialize/URI.js/issues/1))
* fixing parsing "?foo" to `{foo: null}` [Algorithm for collecting URL parameters](http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#collect-url-parameters)
* fixing building `{foo: null, bar: ""}` to "?foo&bar=" [Algorithm for serializing URL parameters](http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#url-parameter-serialization)
* fixing RegExp escaping
### 1.0.0 (December 27th 2011) ###
* Initial URI.js

22
Gruntfile.js Normal file
View File

@ -0,0 +1,22 @@
module.exports = function(grunt) {
'use strict';
var jshintOptions = grunt.file.readJSON('.jshintrc');
jshintOptions.reporter = require('jshint-stylish');
grunt.initConfig({
jshint: {
options: jshintOptions,
target: [
'Gruntfile.js',
'src/*.js',
'test/*.js',
'!src/*.min.js',
'!src/punycode.js'
]
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('lint', 'jshint');
};

21
LICENSE.txt Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2011 Rodney Rehm
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

244
README.md Normal file
View File

@ -0,0 +1,244 @@
# URI.js #
* [About](http://medialize.github.io/URI.js/)
* [Understanding URIs](http://medialize.github.io/URI.js/about-uris.html)
* [Documentation](http://medialize.github.io/URI.js/docs.html)
* [jQuery URI Plugin](http://medialize.github.io/URI.js/jquery-uri-plugin.html)
* [Author](http://rodneyrehm.de/en/)
* [Changelog](./CHANGELOG.md)
---
> **NOTE:** The npm package name changed to `urijs`
---
I always want to shoot myself in the head when looking at code like the following:
```javascript
var url = "http://example.org/foo?bar=baz";
var separator = url.indexOf('?') > -1 ? '&' : '?';
url += separator + encodeURIComponent("foo") + "=" + encodeURIComponent("bar");
```
Things are looking up with [URL](https://developer.mozilla.org/en/docs/Web/API/URL) and the [URL spec](http://url.spec.whatwg.org/) but until we can safely rely on that API, have a look at URI.js for a clean and simple API for mutating URIs:
```javascript
var url = new URI("http://example.org/foo?bar=baz");
url.addQuery("foo", "bar");
```
URI.js is here to help with that.
## API Example ##
```javascript
// mutating URLs
URI("http://example.org/foo.html?hello=world")
.username("rodneyrehm")
// -> http://rodneyrehm@example.org/foo.html?hello=world
.username("")
// -> http://example.org/foo.html?hello=world
.directory("bar")
// -> http://example.org/bar/foo.html?hello=world
.suffix("xml")
// -> http://example.org/bar/foo.xml?hello=world
.query("")
// -> http://example.org/bar/foo.xml
.tld("com")
// -> http://example.com/bar/foo.xml
.query({ foo: "bar", hello: ["world", "mars"] });
// -> http://example.com/bar/foo.xml?foo=bar&hello=world&hello=mars
// cleaning things up
URI("?&foo=bar&&foo=bar&foo=baz&")
.normalizeQuery();
// -> ?foo=bar&foo=baz
// working with relative paths
URI("/foo/bar/baz.html")
.relativeTo("/foo/bar/world.html");
// -> ./baz.html
URI("/foo/bar/baz.html")
.relativeTo("/foo/bar/sub/world.html")
// -> ../baz.html
.absoluteTo("/foo/bar/sub/world.html");
// -> /foo/bar/baz.html
// URI Templates
URI.expand("/foo/{dir}/{file}", {
dir: "bar",
file: "world.html"
});
// -> /foo/bar/world.html
```
See the [About Page](http://medialize.github.io/URI.js/) and [API Docs](http://medialize.github.io/URI.js/docs.html) for more stuff.
## Using URI.js ##
URI.js (without plugins) has a gzipped weight of about 7KB - if you include all extensions you end up at about 13KB. So unless you *need* second level domain support and use URI templates, we suggest you don't include them in your build. If you don't need a full featured URI mangler, it may be worth looking into the much smaller parser-only alternatives [listed below](#alternatives).
URI.js is available through [npm](https://www.npmjs.com/package/urijs), [bower](http://bower.io/search/?q=urijs), [bowercdn](http://bowercdn.net/package/urijs), [cdnjs](https://cdnjs.com/libraries/URI.js) and manually from the [build page](http://medialize.github.io/URI.js/build.html):
```bash
# using bower
bower install uri.js
# using npm
npm install urijs
```
### Browser ###
I guess you'll manage to use the [build tool](http://medialize.github.io/URI.js/build.html) or follow the [instructions below](#minify) to combine and minify the various files into URI.min.js - and I'm fairly certain you know how to `<script src=".../URI.min.js"></script>` that sucker, too.
### Node.js and NPM ###
Install with `npm install urijs` or add `"urijs"` to the dependencies in your `package.json`.
```javascript
// load URI.js
var URI = require('urijs');
// load an optional module (e.g. URITemplate)
var URITemplate = require('urijs/src/URITemplate');
URI("/foo/bar/baz.html")
.relativeTo("/foo/bar/sub/world.html")
// -> ../baz.html
```
### RequireJS ###
Clone the URI.js repository or use a package manager to get URI.js into your project.
```javascript
require.config({
paths: {
urijs: 'where-you-put-uri.js/src'
}
});
require(['urijs/URI'], function(URI) {
console.log("URI.js and dependencies: ", URI("//amazon.co.uk").is('sld') ? 'loaded' : 'failed');
});
require(['urijs/URITemplate'], function(URITemplate) {
console.log("URITemplate.js and dependencies: ", URITemplate._cache ? 'loaded' : 'failed');
});
```
## Minify ##
See the [build tool](http://medialize.github.io/URI.js/build.html) or use [Google Closure Compiler](http://closure-compiler.appspot.com/home):
```
// ==ClosureCompiler==
// @compilation_level SIMPLE_OPTIMIZATIONS
// @output_file_name URI.min.js
// @code_url http://medialize.github.io/URI.js/src/IPv6.js
// @code_url http://medialize.github.io/URI.js/src/punycode.js
// @code_url http://medialize.github.io/URI.js/src/SecondLevelDomains.js
// @code_url http://medialize.github.io/URI.js/src/URI.js
// @code_url http://medialize.github.io/URI.js/src/URITemplate.js
// ==/ClosureCompiler==
```
## Resources ##
Documents specifying how URLs work:
* [URL - Living Standard](http://url.spec.whatwg.org/)
* [RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax](http://tools.ietf.org/html/rfc3986)
* [RFC 3987 - Internationalized Resource Identifiers (IRI)](http://tools.ietf.org/html/rfc3987)
* [RFC 2732 - Format for Literal IPv6 Addresses in URL's](http://tools.ietf.org/html/rfc2732)
* [RFC 2368 - The `mailto:` URL Scheme](https://www.ietf.org/rfc/rfc2368.txt)
* [RFC 2141 - URN Syntax](https://www.ietf.org/rfc/rfc2141.txt)
* [IANA URN Namespace Registry](http://www.iana.org/assignments/urn-namespaces/urn-namespaces.xhtml)
* [Punycode: A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)](http://tools.ietf.org/html/rfc3492)
* [application/x-www-form-urlencoded](http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type) (Query String Parameters) and [application/x-www-form-urlencoded encoding algorithm](http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#application/x-www-form-urlencoded-encoding-algorithm)
* [What every web developer must know about URL encoding](http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding)
Informal stuff
* [Parsing URLs for Fun and Profit](http://tools.ietf.org/html/draft-abarth-url-01)
* [Naming URL components](http://tantek.com/2011/238/b1/many-ways-slice-url-name-pieces)
How other environments do things
* [Java URI Class](http://docs.oracle.com/javase/7/docs/api/java/net/URI.html)
* [Java Inet6Address Class](http://docs.oracle.com/javase/1.5.0/docs/api/java/net/Inet6Address.html)
* [Node.js URL API](http://nodejs.org/docs/latest/api/url.html)
[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 <a> URL Mutation "Hack"](http://jsfiddle.net/rodneyrehm/KkGUJ/) ([jsPerf comparison](http://jsperf.com/idl-attributes-vs-uri-js))
* [URL.js](https://github.com/ericf/urljs)
* [furl (Python)](https://github.com/gruns/furl)
* [mediawiki Uri](https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/resources/mediawiki/mediawiki.Uri.js?view=markup) (needs mw and jQuery)
* [jurlp](https://github.com/tombonner/jurlp)
* [jsUri](https://github.com/derek-watson/jsUri)
#### URL Parsers ####
* [The simple <a> URL Mutation "Hack"](http://jsfiddle.net/rodneyrehm/KkGUJ/) ([jsPerf comparison](http://jsperf.com/idl-attributes-vs-uri-js))
* [URI Parser](http://blog.stevenlevithan.com/archives/parseuri)
* [jQuery-URL-Parser](https://github.com/allmarkedup/jQuery-URL-Parser)
* [Google Closure Uri](https://google.github.io/closure-library/api/class_goog_Uri.html)
* [URI.js by Gary Court](https://github.com/garycourt/uri-js)
#### URI Template ####
* [uri-template](https://github.com/rezigned/uri-template.js) (supporting extraction as well) by Rezigne
* [uri-templates](https://github.com/geraintluff/uri-templates) (supporting extraction as well) by Geraint Luff
* [uri-templates](https://github.com/marc-portier/uri-templates) by Marc Portier
* [uri-templates](https://github.com/geraintluff/uri-templates) by Geraint Luff (including reverse operation)
* [URI Template JS](https://github.com/fxa/uritemplate-js) by Franz Antesberger
* [Temple](https://github.com/brettstimmerman/temple) by Brett Stimmerman
* ([jsperf comparison](http://jsperf.com/uri-templates/2))
#### Various ####
* [TLD.js](https://github.com/oncletom/tld.js) - second level domain names
* [Public Suffix](http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1) - second level domain names
* [uri-collection](https://github.com/scivey/uri-collection) - underscore based utility for working with many URIs
## Authors ##
* [Rodney Rehm](https://github.com/rodneyrehm)
* [Various Contributors](https://github.com/medialize/URI.js/graphs/contributors)
## Contains Code From ##
* [punycode.js](http://mths.be/punycode) - Mathias Bynens
* [IPv6.js](http://intermapper.com/support/tools/IPV6-Validator.aspx) - Rich Brown - (rewrite of the original)
## License ##
URI.js is published under the [MIT license](http://www.opensource.org/licenses/mit-license). Until version 1.13.2 URI.js was also published under the [GPL v3](http://opensource.org/licenses/GPL-3.0) license - but as this dual-licensing causes more questions than helps anyone, it was dropped with version 1.14.0.
## Changelog ##
moved to [Changelog](./CHANGELOG.md)

189
about-uris.html Normal file
View File

@ -0,0 +1,189 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>URI.js - About URIs</title>
<meta name="description" content="URI.js is a Javascript library for working with URLs." />
<script src="jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="prettify/prettify.js" type="text/javascript"></script>
<script src="screen.js" type="text/javascript"></script>
<link href="screen.css" rel="stylesheet" type="text/css" />
<link href="prettify/prettify.sunburst.css" rel="stylesheet" type="text/css" />
<script src="src/URI.min.js" type="text/javascript"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8922143-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<a id="github-forkme" href="https://github.com/medialize/URI.js"><img src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div id="container">
<h1><a href="https://github.com/medialize/URI.js">URI.js</a></h1>
<ul class="menu">
<li><a href="/URI.js/">Intro</a></li>
<li class="active"><a href="about-uris.html">Understanding URIs</a></li>
<li><a href="docs.html">API-Documentation</a></li>
<li><a href="jquery-uri-plugin.html">jQuery Plugin</a></li>
<li><a href="uri-template.html">URI Template</a></li>
<li><a href="build.html">Build</a></li>
<li><a href="http://rodneyrehm.de/en/">Author</a></li>
</ul>
<h2>Understanding URIs</h2>
<p>
Uniform Resource Identifiers (URI) can be one of two things, a Uniform Resource Locator (URL) or a Uniform Resource Name (URN).
You likely deal with URLs most of the time. See RFC 3986 for a proper definition of the terms <a href="http://tools.ietf.org/html/rfc3986#section-1.1.3">URI, URL and URN</a>
</p>
<p>
URNs <em>name</em> a resource.
They are (supposed to) designate a globally unique, permanent identifier for that resource.
For example, the URN <code>urn:isbn:0201896834</code> uniquely identifies Volume 1 of Donald Knuth's <em>The Art of Computer Porgramming</em>.
Even if that book goes out of print, that URN will continue to identify that particular book in that particular printing.
While the term &quot;URN&quot; <em>technically</em> refers to a specific URI scheme laid out by <a href="http://tools.ietf.org/html/rfc2141">RFC 2141</a>,
the previously-mentioned RFC 3986 indicates that in common usage &quot;URN&quot; refers to any kind of URI that identifies a resource.
</p>
<p>
URLs <em>locate</em> a resource.
They designate a protocol to use when looking up the resource and provide an &quot;address&quot; for finding the resource within that scheme.
For example, the URL <code><a href="http://tools.ietf.org/html/rfc3986">http://tools.ietf.org/html/rfc3986</a></code> tells the consumer (most likely a web browser)
to use the HTTP protocol to access whatever site is found at the <code>/html/rfc3986</code> path of <code>tools.ietf.org</code>.
URLs are not permanent; it is possible that in the future that the IETF will move to a different domain or even that some other organization will acquire the rights to <code>tools.ietf.org</code>.
It is also possible that multiple URLs may locate the same resource;
for example, an admin at the IETF might be able to access the document found at the example URL via the <code>ftp://</code> protocol.
</p>
<h2>URLs and URNs in URI.js</h2>
<p>
The distinction between URLs and URNs is one of <strong>semantics</strong>.
In principle, it is impossible to tell, on a purely syntactical level, whether a given URI is a URN or a URL without knowing more about its scheme.
Practically speaking, however, URIs that look like HTTP URLs (scheme is followed by a colon and two slashes, URI has an authority component, and paths are delimited by slashes) tend to be URLs,
and URIs that look like RFC 2141 URNs (scheme is followed by a colon, no authority component, and paths are delimited by colons) tend to be URNs (in the broad sense of &quot;URIs that name&quot;).
</p>
<p>
So, for the purposes of URI.js, the distinction between URLs and URNs is treated as one of <strong>syntax</strong>.
The main functional differences between the two are that (1) URNs will not have an authority element and
(2) when breaking the path of the URI into segments, the colon will be used as the delimiter rather than the slash.
The most surprising result of this is that <code>mailto:</code> URLs will be considered by URI.js to be URNs rather than URLs.
That said, the functional differences will not adversely impact the handling of those URLs.
</p>
<h2 id="components">Components of an URI</h2>
<p><a href="http://tools.ietf.org/html/rfc3986#section-3">RFC 3986 Section 3</a> visualizes the structure of <abbr title="Uniform Resource Indicator">URI</abbr>s as follows:</p>
<pre class="ascii-art">
URL: foo://example.com:8042/over/there?name=ferret#nose
<span class="line"> \_/ \______________/\_________/ \_________/ \__/
| | | | |
</span><span class="label"> scheme authority path query fragment
</span><span class="line"> | _____________________|__
/ \ / \
</span>URN: urn:example:animal:ferret:nose</pre>
<h3 id="components-url">Components of an <abbr title="Uniform Resource Locator">URL</abbr> in URI.js</h3>
<pre class="ascii-art">
<a href="docs.html#accessors-origin">origin</a>
<span class="line"> __________|__________
/ \
</span> <a href="docs.html#accessors-authority">authority</a>
<span class="line"> | __________|_________
| / \
</span> <a href="docs.html#accessors-userinfo">userinfo</a> <a href="docs.html#accessors-host">host</a> <a href="docs.html#accessors-resource">resource</a>
<span class="line"> | __|___ ___|___ __________|___________
| / \ / \ / \
</span> <a href="docs.html#accessors-username">username</a> <a href="docs.html#accessors-password">password</a> <a href="docs.html#accessors-hostname">hostname</a> <a href="docs.html#accessors-port">port</a> <a href="docs.html#accessors-pathname">path</a> &amp; <a href="docs.html#accessors-segment">segment</a> <a href="docs.html#accessors-search">query</a> <a href="docs.html#accessors-hash">fragment</a>
<span class="line"> | __|___ __|__ ______|______ | __________|_________ ____|____ |
| / \ / \ / \ / \ / \ / \ / \
</span> foo://username:password@www.example.com:123/hello/world/there.html?name=ferret#foo
<span class="line"> \_/ \ / \ \ / \__________/ \ \__/
| | \ | | \ |
</span> <a href="docs.html#accessors-protocol">scheme</a> <a href="docs.html#accessors-subdomain">subdomain</a> <span class="line">\</span> <a href="docs.html#accessors-tld">tld</a> <a href="docs.html#accessors-directory">directory</a> <span class="line">\</span> <a href="docs.html#accessors-suffix">suffix</a>
<span class="line"> \____/ \___/
| |
</span> <a href="docs.html#accessors-domain">domain</a> <a href="docs.html#accessors-filename">filename</a>
</pre>
<p>
In Javascript the <em>query</em> is often referred to as the <em>search</em>.
URI.js provides both accessors with the subtle difference of <a href="docs.html#accessors-search">.search()</a> beginning with the <code>?</code>-character
and <a href="docs.html#accessors-search">.query()</a> not.
</p>
<p>
In Javascript the <em>fragment</em> is often referred to as the <em>hash</em>.
URI.js provides both accessors with the subtle difference of <a href="docs.html#accessors-hash">.hash()</a> beginning with the <code>#</code>-character
and <a href="docs.html#accessors-hash">.fragment()</a> not.
</p>
<h3 id="components-urn">Components of an <abbr title="Uniform Resource Name">URN</abbr> in URI.js</h3>
<pre class="ascii-art">
urn:example:animal:ferret:nose?name=ferret#foo
<span class="line"> \ / \________________________/ \_________/ \ /
| | | |
</span> <a href="docs.html#accessors-protocol">scheme</a> <a href="docs.html#accessors-pathname">path</a> &amp; <a href="docs.html#accessors-segment">segment</a> <a href="docs.html#accessors-search">query</a> <a href="docs.html#accessors-hash">fragment</a>
</pre>
<p>While <a href="http://tools.ietf.org/html/rfc2141">RFC 2141</a> does not define URNs having a query or fragment component, URI.js enables these accessors for convenience.</p>
<h2 id="problems">URLs - Man Made Problems</h2>
<p>URLs (URIs, whatever) aren't easy. There are a couple of issues that make this simple text representation of a resource a real pain</p>
<ul>
<li>Look simple but have tricky encoding issues</li>
<li>Domains aren't part of the specification</li>
<li>Query String Format isn't part of the specification</li>
<li>Environments (PHP, JS, Ruby, …) handle Query Strings quite differently</li>
</ul>
<h3 id="problems-encoding">Parsing (seemingly) invalid URLs</h3>
<p>Because URLs look very simple, most people haven't read the formal specification. As a result, most people get URLs wrong on many different levels. The one thing most everybody screws up is proper encoding/escaping.</p>
<p><code>http://username:pass:word@example.org/</code> is such a case. Often times homebrew URL handling misses escaping the less frequently used parts such as the userinfo.</p>
<p><code>http://example.org/@foo</code> that "@" doesn't have to be escaped according to RFC3986. Homebrew URL handlers often just treat everything between "://" and "@" as the userinfo.</p>
<p><code>some/path/:foo</code> is a valid relative path (as URIs don't have to contain scheme and authority). Since homebrew URL handlers usually just look for the first occurence of ":" to delimit the scheme, they'll screw this up as well.</p>
<p><code>+</code> is the proper escape-sequence for a space-character within the query string component, while every other component prefers <code>%20</code>. This is due to the fact that the actual format used within the query string component is not defined in RFC 3986, but in the HTML spec.</p>
<p>There is encoding and strict encoding - and Javascript won't get them right: <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent#Description">encodeURIComponent()</a></p>
<h3 id="problems-tld">Top Level Domains</h3>
<p>The hostname component can be one of may things. An IPv4 or IPv6 address, an IDN or Punycode domain name, or a regular domain name. While the format (and meaning) of IPv4 and IPv6 addresses is defined in RFC 3986, the meaning of domain names is not.</p>
<p>DNS is the base of translating domain names to IP addresses. DNS itself only specifies syntax, not semantics. The missing semantics is what's driving us crazy here.</p>
<p>ICANN provides a <a href="http://www.iana.org/domains/root/db/">list of registered Top Level Domains</a> (TLD). There are country code TLDs (ccTLDs, assigned to each country, like ".uk" for United Kindom) and generic TLDs (gTLDs, like ".xxx" for you know what). Also note that a TLD may be non-ASCII <code>.香港</code> (IDN version of HK, Hong Kong).</p>
<p>IDN TLDs such as <code>.香港</code> and the fact that any possible new TLD could pop up next month has lead to a lot of URL/Domain verification tools to fail.</p>
<h3 id="problems-sld">Second Level Domains</h3>
<p>To make Things worse, people thought it to be a good idea to introduce Second Level Domains (SLD, ".co.uk" - the commercial namespace of United Kingdom). These SLDs are not up to ICANN to define, they're handled individually by each NIC (Network Information Center, the orgianisation responsible for a specific TLD).</p>
<p>Since there is no central oversight, things got really messy in this particular space. Germany doesn't do SDLs, Australia does. Australia has different SLDs than the United Kingdom (".csiro.au" but no ".csiro.uk"). The individual NICs are not required to publish their arbitrarily chosen SLDs in a defined syntax anywhere.</p>
<p>You can scour each NIC's website to find some hints at their SLDs. You can look them up on Wikipedia and hope they're right. Or you can use <a href="http://publicsuffix.org/">PublicSuffix</a>.</p>
<p>Speaking of PublicSuffix, it's time mentioning that browser vendors actually keep a list of known Second Level Domains. They need to know those for security issues. Remember cookies? They can be read and set on a domain level. What do you think would happen if "co.uk" was treated as the domain? <code>amazon.co.uk</code> would be able to read the cookies of <code>google.co.uk</code>. PublicSuffix also contains custom SLDs, such as <code>.dyndns.org</code>. While this makes perfect sense for browser security, it's not what we need for basic URL handling.</p>
<p>TL;DR: It's a mess.</p>
<h3 id="problems-querystring">The Query String</h3>
<p>PHP (<a href="http://php.net/manual/en/function.parse-str.php">parse_str()</a>) will automatically parse the query string and populate the superglobal <code>$_GET</code> for you. <code>?foo=1&amp;foo=2</code> becomes <code>$_GET = array('foo' => 2);</code>, while <code>?foo[]=1&amp;foo[]=2</code> becomes <code>$_GET = array('foo' => array("1", "2"));</code>.</p>
<p>Ruby's <code>CGI.parse()</code> turns <code>?a=1&amp;a=2</code> into <code>{"a" : ["1", "2"]}</code>, while Ruby on Rails chose the PHP-way.</p>
<p>Python's <a href="http://docs.python.org/2/library/urlparse.html#urlparse.parse_qs">parse_qs()</a> doesn't care for <code>[]</code> either.
<p>Most other languages don't follow the <code>[]</code>-style array-notation and deal with this mess differently.</p>
<p>TL;DR: You need to know the target-environment, to know how complex query string data has to be encoded</p>
<h3 id="problems-fragment">The Fragment</h3>
<p>Given the URL <code>http://example.org/index.html#foobar</code>, browsers only request <code>http://example.org/index.html</code>, the fragment <code>#foobar</code> is a client-side thing.</p>
</div>
</body>
</html>

16
bower.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "urijs",
"version": "1.18.2",
"main": "src/URI.js",
"ignore": [
".*",
"*.css",
"/*.js",
"/*.html",
"/*.json",
"utils",
"test",
"prettify"
],
"license": "MIT"
}

71
build.html Normal file
View File

@ -0,0 +1,71 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>URI.js - Custom Build</title>
<meta name="description" content="URI.js is a Javascript library for working with URLs." />
<script src="jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="screen.js" type="text/javascript"></script>
<script src="build.js" type="text/javascript"></script>
<link href="screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a id="github-forkme" href="https://github.com/medialize/URI.js"><img src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div id="container">
<h1><a href="https://github.com/medialize/URI.js">URI.js</a></h1>
<ul class="menu">
<li><a href="/URI.js/">Intro</a></li>
<li><a href="about-uris.html">Understanding URIs</a></li>
<li><a href="docs.html">API-Documentation</a></li>
<li><a href="jquery-uri-plugin.html">jQuery Plugin</a></li>
<li><a href="uri-template.html">URI Template</a></li>
<li class="active"><a href="build.html">Build</a></li>
<li><a href="http://rodneyrehm.de/en/">Author</a></li>
</ul>
<h2>Building URI.js</h2>
<p>
<strong>Warning:</strong> The output of this "build tool" is not compatible
with module loaders (like RequireJS), because it only concatenates and minifies files.
Only use this if you plan on loading the file by way of <code>&lt;script&gt;</code> element.
</p>
<p>Choose the Modules you want to include in your custom build of URI.js:</p>
<form id="builder">
<ul>
<li><label><input type="checkbox" value="IPv6.js" checked> IPv6.js - Support for IPv6 Addresses</label></li>
<li><label><input type="checkbox" value="punycode.js" checked> punycode.js - Support for IDN Addresses</label></li>
<li><label><input type="checkbox" value="SecondLevelDomains.js" checked> SecondLevelDomains.js - Support for resolving SLDs</label></li>
<li><label><input type="checkbox" value="URI.js" checked readonly disabled> URI.js - Base URI.js</label></li>
<li><label><input type="checkbox" value="URITemplate.js" checked> URITemplate.js - Support for <a href="uri-template.html">URI Templates</a></label></li>
<li><label><input type="checkbox" value="jquery.URI.js" checked> jquery.URI.js - <a href="jquery-uri-plugin.html">jQuery Plugin</a></label></li>
</ul>
<p>Optional "Fragment Abuse" plugins:</p>
<ul>
<li><label><input type="radio" name="fragments" value="" checked> No Fragment abuse</label></li>
<li><label><input type="radio" name="fragments" value="URI.fragmentQuery.js"> URI.fragmentQuery.js - support for <a href="docs.html#fragment-abuse-query">Query String Fragments</a></label></li>
<li><label><input type="radio" name="fragments" value="URI.fragmentURI.js"> URI.fragmentURI.js - support for <a href="docs.html#fragment-abuse-uri">URI Fragments</a></label></li>
</ul>
<input type="submit" value="Build!">
<progress id="prog" value="0" max="3" style="display:none"></progress>
<div style="display:none;">
<h2>Custom Built URI.js</h2>
<p class="download"> your custom built <code>URI.js</code> or copy the following code:</p>
<textarea id="output" cols="50" rows="5" style="width: 100%; height: 200px;"></textarea>
</div>
<hr>
<p>
This "build tool" does nothing but downloading the selected files, concatenating them and pushing them through <a href="http://closure-compiler.appspot.com/home">Closure Compiler</a>.
Since Closure Compiler is running on a different domain, this trick will only work on modern browsers.
I'm sorry for the ~2% of you IE users. You'll have to do this <a href="https://github.com/medialize/URI.js#minify">manually</a>.
</p>
</form>
</div>
</body>
</html>

78
build.js Normal file
View File

@ -0,0 +1,78 @@
(function($, undefined){
window.URL = window.webkitURL || window.URL;
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
function build(files) {
var $out = $('#output'),
$progress = $('#prog'),
sources = [],
connections = [],
source;
$out.parent().hide();
$progress.show().prop('value', 1).text('Loading Files');
for (var i = 0, length = files.length; i < length; i++) {
sources.push("");
(function(i, file){
connections.push($.get("src/" + file, function(data) {
sources[i] = data;
}, "text"));
})(i, files[i]);
}
$.when.apply($, connections).done(function() {
$progress.prop('value', 2).text('Compiling Scripts');
$.post('https://closure-compiler.appspot.com/compile', {
js_code: sources.join("\n\n"),
compilation_level: "SIMPLE_OPTIMIZATIONS",
output_format: "text",
output_info: "compiled_code"
}, function(data) {
var code = "/*! URI.js v1.18.2 http://medialize.github.io/URI.js/ */\n/* build contains: " + files.join(', ') + " */\n" + data;
$progress.hide();
$out.val(code).parent().show();
$out.prev().find('a').remove();
$out.prev().prepend(download(code));
}).error(function() {
alert("Your browser is incapable of cross-domain communication.\nPlease see instructions for manual build below.");
});
});
};
function download(code) {
var blob = new Blob([code], {type: 'text\/javascript'});
var a = document.createElement('a');
a.download = 'URI.js';
a.href = window.URL.createObjectURL(blob);
a.textContent = 'Download';
a.dataset.downloadurl = ['text/javascript', a.download, a.href].join(':');
return a;
};
$(function(){
$('#builder').on('submit', function(e) {
var $this = $(this),
$files = $this.find('input:checked'),
files = [];
e.preventDefault();
e.stopImmediatePropagation();
if (!$files.length) {
alert("please choose at least one file!");
return;
}
$files.each(function() {
var val = $(this).val();
val.length && files.push(val);
});
build(files);
});
});
})(jQuery);

19
contributing.md Normal file
View File

@ -0,0 +1,19 @@
# Contributing to URI.js #
URI.js Project License: MIT License
* You will only Submit Contributions where You have authored 100% of the content.
* You will only Submit Contributions to which You have the necessary rights. This means that if You are employed You have received the necessary permissions from Your employer to make the Contributions.
* Whatever content You Contribute will be provided under the project License.
---
Thanks for your help!
Pull Requests go into the branch **master**. The *gh-pages* branch is a presentation of the *master* branch at the last given release.
Whenever you change code, make sure you run the test suite before sending a pull request. Please add tests for any features you add to the code base. We're using [QUnit](http://qunitjs.com/) for testing.
We're looking forward to splitting URI.js in several files, each dealing with a specific domain, to make the 1800 lines of code more bearable to work with. This will lead to using [Grunt](http://gruntjs.com/) to build a distributable version (and the removal of `build.html`). We're not sure when we'll get to this. If you want to pitch in, just holler!

1399
docs.html Normal file

File diff suppressed because it is too large Load Diff

173
index.html Normal file
View File

@ -0,0 +1,173 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>URI.js - URLs in Javascript</title>
<meta name="description" content="URI.js is a Javascript library for working with URLs." />
<script src="jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="prettify/prettify.js" type="text/javascript"></script>
<script src="screen.js" type="text/javascript"></script>
<link href="screen.css" rel="stylesheet" type="text/css" />
<link href="prettify/prettify.sunburst.css" rel="stylesheet" type="text/css" />
<script src="src/URI.min.js" type="text/javascript"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8922143-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<a id="github-forkme" href="https://github.com/medialize/URI.js"><img src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div id="github-watch"><a href="https://github.com/medialize/URI.js" class="gitwatch">URI.js Github Repository</a></div>
<div id="container">
<h1><a href="https://github.com/medialize/URI.js">URI.js</a></h1>
<ul class="menu">
<li class="active"><a href="/URI.js/">Intro</a></li>
<li><a href="about-uris.html">Understanding URIs</a></li>
<li><a href="docs.html">API-Documentation</a></li>
<li><a href="jquery-uri-plugin.html">jQuery Plugin</a></li>
<li><a href="uri-template.html">URI Template</a></li>
<li><a href="build.html">Build</a></li>
<li><a href="http://rodneyrehm.de/en/">Author</a></li>
</ul>
<p>URI.js is a javascript library for working with URLs. It offers a "jQuery-style" API (<a href="http://en.wikipedia.org/wiki/Fluent_interface">Fluent Interface</a>, Method Chaining) to read and write all regular components and a number of convenience methods like
.<a href="docs.html#accessors-directory">directory</a>() and .<a href="docs.html#accessors-authority">authority</a>().</p>
<p>URI.js offers simple, yet powerful ways of working with query string, has a number of URI-normalization functions and converts relative/absolute paths.</p>
<p>While URI.js provides a <a href="jquery-uri-plugin.html">jQuery plugin</a>. URI.js itself does not rely on jQuery. You <em>don't need jQuery</em> to use URI.js</p>
<h2>Examples</h2>
<p>How do you like manipulating URLs the "jQuery-style"?</p>
<pre class="prettyprint lang-js">// mutating URLs
URI("http://example.org/foo.html?hello=world")
.<a href="docs.html#accessors-username">username</a>("rodneyrehm")
// -> http://rodneyrehm@example.org/foo.html?hello=world
.<a href="docs.html#accessors-username">username</a>("")
// -> http://example.org/foo.html?hello=world
.<a href="docs.html#accessors-directory">directory</a>("bar")
// -> http://example.org/bar/foo.html?hello=world
.<a href="docs.html#accessors-suffix">suffix</a>("xml")
// -> http://example.org/bar/foo.xml?hello=world
.<a href="docs.html#accessors-hash">hash</a>("hackernews")
// -> http://example.org/bar/foo.xml?hello=world#hackernews
.<a href="docs.html#accessors-fragment">fragment</a>("")
// -> http://example.org/bar/foo.xml?hello=world
.<a href="docs.html#accessors-search">search</a>("") // alias of .query()
// -> http://example.org/bar/foo.xml
.<a href="docs.html#accessors-tld">tld</a>("com")
// -> http://example.com/bar/foo.xml
.<a href="docs.html#accessors-search">search</a>({ foo: "bar", hello: ["world", "mars"] });
// -> http://example.com/bar/foo.xml?foo=bar&amp;hello=world&amp;hello=mars</pre>
<p>How do you like working query strings?</p>
<pre class="prettyprint lang-js">URI("?hello=world")
.<a href="docs.html#search-add">addSearch</a>("hello", "mars")
// -> ?hello=world&amp;hello=mars
.<a href="docs.html#search-add">addSearch</a>({ foo: ["bar", "baz"] })
// -> ?hello=world&amp;hello=mars&amp;foo=bar&amp;foo=baz
.<a href="docs.html#search-remove">removeSearch</a>("hello", "mars")
// -> ?hello=world&amp;foo=bar&amp;foo=baz
.<a href="docs.html#search-remove">removeSearch</a>("foo")
// -> ?hello=world
</pre>
<p>How do you like relative paths?</p>
<pre class="prettyprint lang-js">URI("/relative/path")
.<a href="docs.html#relativeto">relativeTo</a>("/relative/sub/foo/sub/file")
// -> ../../../path
.<a href="docs.html#absolute">absoluteTo</a>("/relative/sub/foo/sub/file");
// -> /relative/path </pre>
<p>How do you like cleaning things up?</p>
<pre class="prettyprint lang-js">URI("?&amp;foo=bar&amp;&amp;foo=bar&amp;foo=baz&amp;&quot;)
.<a href="docs.html#normalize-search">normalizeSearch</a>();
// -&gt; ?foo=bar&amp;foo=baz
URI("/hello/foo/woo/.././../world.html")
.<a href="docs.html#normalize-path">normalizePathname</a>();
// -> /hello/world.html </pre>
<p>How do you like detecting URIs within random text?</p>
<pre class="prettyprint lang-js">var source = "Hello www.example.com,\n"
+ "http://google.com is a search engine, like http://www.bing.com\n"
+ "http://exämple.org/foo.html?baz=la#bumm is an IDN URL,\n"
+ "http://123.123.123.123/foo.html is IPv4 and "
+ "http://fe80:0000:0000:0000:0204:61ff:fe9d:f156/foobar.html is IPv6.\n"
+ "links can also be in parens (http://example.org) "
+ "or quotes »http://example.org«.";
var result = <a href="docs.html#static-withinString">URI.withinString</a>(source, function(url) {
return "&lt;a&gt;" + url + "&lt;/a&gt;";
});
/* result is:
Hello <strong>&lt;a&gt;www.example.com&lt;/a&gt;</strong>,
<strong>&lt;a&gt;http://google.com&lt;/a&gt;</strong> is a search engine, like <strong>&lt;a&gt;http://www.bing.com&lt;/a&gt;</strong>
<strong>&lt;a&gt;http://ex&auml;mple.org/foo.html?baz=la#bumm&lt;/a&gt;</strong> is an IDN URL,
<strong>&lt;a&gt;http://123.123.123.123/foo.html&lt;/a&gt;</strong> is IPv4 and <strong>&lt;a&gt;http://fe80:0000:0000:0000:0204:61ff:fe9d:f156/foobar.html&lt;/a&gt;</strong> is IPv6.
links can also be in parens (<strong>&lt;a&gt;http://example.org&lt;/a&gt;</strong>) or quotes &raquo;<strong>&lt;a&gt;http://example.org&lt;/a&gt;</strong>&laquo;.
*/
</pre>
<p>How do you like comparing URLs?</p>
<pre class="prettyprint lang-js">var a = "http://example.org/foo/bar.html"
+ "?foo=bar&amp;hello=world&amp;hello=mars#fragment",
b = "http://exAMPle.org:80/foo/../foo/bar.html"
+ "?hello=mars&amp;foo=bar&amp;hello=world&amp;#fragment";
a !== b;
URI(a).<a href="docs.html#equals">equals</a>(b) === true;</pre>
<p>How do you like fiddling with the fragment?</p>
<pre class="prettyprint lang-js">// <strong>storing values in the fragment (hash):</strong>
var uri = URI("#hello-world");
uri.fragment({foo: "bar", bar: ["hello", "world"]});
uri.fragment() === "foo=bar&amp;bar=hello&amp;bar=world";
// required src/URI.fragmentQuery.js to be loaded
// <strong>storing URLs in the fragment (hash):</strong>
var uri = URI("http://example.org/#!/foo/bar/baz.html"),
furi = uri.fragment(true);
furi.pathname() === "/foo/bar/baz.html";
furi.pathname("/hello.html");
uri.toString() === "http://example.org/#!/hello.html"
// required src/URI.fragmentURI.js to be loaded</pre>
<p>How do you like parsing URNs?</p>
<pre class="prettyprint lang-js">var uri = URI("urn:uuid:c5542ab6-3d96-403e-8e6b-b8bb52f48d9a?query=string");
uri.protocol() == "urn";
uri.path() == "uuid:c5542ab6-3d96-403e-8e6b-b8bb52f48d9a";
uri.query() == "query=string";</pre>
<p>How do you like URI Templating?</p>
<pre class="prettyprint lang-js">URI.expand("/foo/{dir}/{file}", {
dir: "bar",
file: "world.html"
});
// -> /foo/bar/world.html</pre>
<h2 id="authors">Authors</h2>
<ul>
<li><a href="http://rodneyrehm.de/en/">Rodney Rehm</a></li>
</ul>
<h2 id="license">License</h2>
<p>URI.js is published under the <a href="http://www.opensource.org/licenses/mit-license">MIT license</a>.</p>
</div>
<script type="text/javascript" src="https://raw.github.com/addyosmani/github-watchers-button/master/github-watchers.min.js"></script>
</body>
</html>

6
jquery-1.10.2.min.js vendored Normal file

File diff suppressed because one or more lines are too long

4
jquery-1.7.2.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
jquery-1.8.2.min.js vendored Normal file

File diff suppressed because one or more lines are too long

5
jquery-1.9.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

203
jquery-uri-plugin.html Normal file
View File

@ -0,0 +1,203 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>URI.js - jQuery URI Plugin</title>
<meta name="description" content="URI.js is a Javascript library for working with URLs." />
<script src="jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="prettify/prettify.js" type="text/javascript"></script>
<script src="screen.js" type="text/javascript"></script>
<link href="screen.css" rel="stylesheet" type="text/css" />
<link href="prettify/prettify.sunburst.css" rel="stylesheet" type="text/css" />
<script src="src/URI.min.js" type="text/javascript"></script>
<script src="src/jquery.URI.js" type="text/javascript"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8922143-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<a id="github-forkme" href="https://github.com/medialize/URI.js"><img src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div id="container">
<h1><a href="https://github.com/medialize/URI.js">URI.js</a></h1>
<ul class="menu">
<li><a href="/URI.js/">Intro</a></li>
<li><a href="about-uris.html">Understanding URIs</a></li>
<li><a href="docs.html">API-Documentation</a></li>
<li class="active"><a href="jquery-uri-plugin.html">jQuery Plugin</a></li>
<li><a href="uri-template.html">URI Template</a></li>
<li><a href="build.html">Build</a></li>
<li><a href="http://rodneyrehm.de/en/">Author</a></li>
</ul>
<h2>URI.js jQuery Plugin</h2>
<p>As of version 1.6.0 URI.js offers a simple jQuery integration. For the plugin to work, you need to regularly load <code>URI.js</code>, as well as <code>jquery.URI.js</code>.</p>
<p>URI.js does not depend on jQuery unless you want to use the URI.js jQuery Plugin</p>
<h2>Accessing the URI Instance</h2>
<pre class="prettyprint lang-js">
var $a = $('&lt;a href=&quot;http://google.com/hello.html&quot;&gt;Demo&lt;/a&gt;');
var uri = $a.uri();
// URI instance and DOMElement are always in sync
uri.domain() == 'google.com';
uri.domain('example.org');
$a.attr('href') == 'http://example.org/hello.html';
// access to <strong>href</strong>, <strong>src</strong> and <strong>action</strong>
// transparently update the URI instance
$a.attr('href', '/other.file');
uri.href() == '/other.file';
// $.fn.uri() passes values to DOM and URI
$a.uri('/hello/world.html');
$a.attr('href') == '/hello/world.html';
uri.href() == '/hello/world.html';</pre>
<h2>Accessing URI components</h2>
<pre class="prettyprint lang-js">var $a = $('&lt;a href=&quot;http://www.google.com/hello.html&quot;&gt;Demo&lt;/a&gt;');
// read
$a.attr('uri:domain') == 'google.com';
// write
$a.attr('uri:domain', 'example.org');
$a.attr('href') == 'http://www.example.org/hello.html';</pre>
<p>All URI-component accessors (except <a href="docs.html#accessors-segment">segment</a>) can be used:
<a href="docs.html#accessors-origin">origin</a>,
<a href="docs.html#accessors-authority">authority</a>,
<a href="docs.html#accessors-directory">directory</a>,
<a href="docs.html#accessors-domain">domain</a>,
<a href="docs.html#accessors-filename">filename</a>,
<a href="docs.html#accessors-hash">fragment</a>,
<a href="docs.html#accessors-hash">hash</a>,
<a href="docs.html#accessors-host">host</a>,
<a href="docs.html#accessors-hostname">hostname</a>,
<a href="docs.html#accessors-href">href</a>,
<a href="docs.html#accessors-password">password</a>,
<a href="docs.html#accessors-path">path</a>,
<a href="docs.html#accessors-pathname">pathname</a>,
<a href="docs.html#accessors-port">port</a>,
<a href="docs.html#accessors-protocol">protocol</a>,
<a href="docs.html#accessors-search">query</a>,
<a href="docs.html#accessors-protocol">scheme</a>,
<a href="docs.html#accessors-resource">resource</a>,
<a href="docs.html#accessors-search">search</a>,
<a href="docs.html#accessors-subdomain">subdomain</a>,
<a href="docs.html#accessors-suffix">suffix</a>,
<a href="docs.html#accessors-tld">tld</a>,
<a href="docs.html#accessors-username">username</a>.
</p>
<h2>Selectors</h2>
<p>You may find yourself wanting to select all links to a certain file-type or a specific domain. <code>:uri()</code> is a pseudo-class filter that will help you with that:</p>
<pre class="prettyprint lang-html">
&lt;div class=&quot;first&quot;&gt;
&lt;a href=&quot;/my.pdf?with=query&quot;&gt;PDF&lt;/a&gt;
&lt;a href=&quot;http://google.com/&quot;&gt;Google1&lt;/a&gt;
&lt;/div&gt;
&lt;div class=&quot;second&quot;&gt;
&lt;a href=&quot;http://www.google.com/&quot;&gt;Google2&lt;/a&gt;
&lt;a href=&quot;https://github.com/some/directory/help.html&quot;&gt;Github&lt;/a&gt;
&lt;/div&gt;
</pre>
<pre class="prettyprint lang-js">// finding links to a given file-type
$('a:uri(suffix = pdf)');
// -&gt; finds PDF
// selecting links to a directory (or child thereof)
$('a:uri(directory *= /directory/)');
// -&gt; finds Github
// selecting links to google.com
$('a:uri(domain = google.com)');
// -&gt; finds Google1, Google2
// selecting all relative links
$('a:uri(is: relative)');
// -&gt; finds PDF
// selecting links regardless of their representation
$('a:uri(equals: http://github.com/some/other/../directory/help.html)');
// -&gt; finds Github
// finding elements containing a link to github
$('div').has('a:uri(domain = github)')
// -&gt; finds div.second
// testing if the protocol matches
$('a').eq(1).is(':uri(protocol = http)');
// -&gt; is true
// event delegation
$(document).on('click', 'a:uri(scheme=javscript)', function(e) {
if (!confirm("do you really want to execute this script?\n\n" + this.href)) {
e.preventDefault();
e.stopImmediatePropagation();
}
});</pre>
<h3>The :uri() pseudo selector</h3>
<p><code>:uri()</code> accepts the following three argument patterns:</p>
<ul>
<li><code>:uri(<em>accessor</em> operator <strong>string</strong>)</code> to compare a single URI-component</li>
<li><code>:uri(is: <strong>string</strong>)</code> to compare against <a href="docs.html#is">.is()</a></li>
<li><code>:uri(equals: <strong>string</strong>)</code> to compare URLs using <a href="docs.html#equals">.equals()</a></li>
</ul>
<p>Note: It is a good idea to prepend the element(s) you're looking for. <code>a:uri(is: relative)</code> is much faster than <code>:uri(is: relative)</code>.</p>
<p>Note: <code>")"</code> may not be used in your comparison-<code>string</code>, as jQuery (Sizzle, actually) can't handle that properly.</p>
<h3>Comparison Accessors</h3>
<p>All URI-component accessors (except <a href="docs.html#accessors-segment">segment</a>) can be used:
<a href="docs.html#accessors-authority">authority</a>,
<a href="docs.html#accessors-directory">directory</a>,
<a href="docs.html#accessors-domain">domain</a>,
<a href="docs.html#accessors-filename">filename</a>,
<a href="docs.html#accessors-hash">fragment</a>,
<a href="docs.html#accessors-hash">hash</a>,
<a href="docs.html#accessors-host">host</a>,
<a href="docs.html#accessors-hostname">hostname</a>,
<a href="docs.html#accessors-href">href</a>,
<a href="docs.html#accessors-password">password</a>,
<a href="docs.html#accessors-path">path</a>,
<a href="docs.html#accessors-pathname">pathname</a>,
<a href="docs.html#accessors-port">port</a>,
<a href="docs.html#accessors-protocol">protocol</a>,
<a href="docs.html#accessors-search">query</a>,
<a href="docs.html#accessors-protocol">scheme</a>,
<a href="docs.html#accessors-resource">resource</a>,
<a href="docs.html#accessors-search">search</a>,
<a href="docs.html#accessors-subdomain">subdomain</a>,
<a href="docs.html#accessors-suffix">suffix</a>,
<a href="docs.html#accessors-tld">tld</a>,
<a href="docs.html#accessors-username">username</a>.
</p>
<h3>Comparison Operators</h3>
<p>Comparison operators are derived from CSS attribute match operators:</p>
<dl>
<dt>=</dt><dd>Exact match of <code>accessor</code> and <code>string</code></dd>
<dt>^=</dt><dd><code>accessor</code> begins with <code>string</code> (case-insensitive)</dd>
<dt>$=</dt><dd><code>accessor</code> ends with <code>string</code> (case-insensitive)</dd>
<dt>*=</dt><dd><code>accessor</code> contains <code>string</code> (case-insensitive)</dd>
</dl>
</div>
</body>
</html>

78
package.json Normal file
View File

@ -0,0 +1,78 @@
{
"name": "urijs",
"version": "1.18.2",
"title": "URI.js - Mutating URLs",
"author": {
"name": "Rodney Rehm",
"url": "http://rodneyrehm.de"
},
"repository": {
"type": "git",
"url": "https://github.com/medialize/URI.js.git"
},
"license": "MIT",
"description": "URI.js is a Javascript library for working with URLs.",
"keywords": [
"uri",
"url",
"urn",
"uri mutation",
"url mutation",
"uri manipulation",
"url manipulation",
"uri template",
"url template",
"unified resource locator",
"unified resource identifier",
"query string",
"RFC 3986",
"RFC3986",
"RFC 6570",
"RFC6570",
"jquery-plugin",
"ecosystem:jquery"
],
"categories": [
"Parsers & Compilers",
"Utilities"
],
"main": "./src/URI",
"homepage": "http://medialize.github.io/URI.js/",
"contributors": [
"Francois-Guillaume Ribreau <npm@fgribreau.com> (http://fgribreau.com)",
"Justin Chase <justin.m.chase@gmail.com> (http://justinmchase.com)"
],
"files": [
"src/URI.js",
"src/IPv6.js",
"src/SecondLevelDomains.js",
"src/punycode.js",
"src/URITemplate.js",
"src/jquery.URI.js",
"src/URI.min.js",
"src/jquery.URI.min.js",
"src/URI.fragmentQuery.js",
"src/URI.fragmentURI.js",
"LICENSE.txt"
],
"npmName": "urijs",
"npmFileMap": [
{
"basePath": "/src/",
"files": [
"*.js"
]
},
{
"basePath": "/",
"files": [
"LICENSE.txt"
]
}
],
"devDependencies": {
"jshint-stylish": "~0.1.5",
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.8.0"
}
}

2
prettify/lang-apollo.js Normal file
View File

@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\n\r]*/,null,"#"],["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r Â\xa0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/,
null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[ES]?BANK=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[!-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["apollo","agc","aea"]);

18
prettify/lang-clj.js Normal file
View File

@ -0,0 +1,18 @@
/*
Copyright (C) 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var a=null;
PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[([{]+/,a,"([{"],["clo",/^[)\]}]+/,a,")]}"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \xa0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/,a],
["typ",/^:[\dA-Za-z-]+/]]),["clj"]);

2
prettify/lang-css.js Normal file
View File

@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);

1
prettify/lang-go.js Normal file
View File

@ -0,0 +1 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r Â\xa0"],["pln",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])+(?:'|$)|`[^`]*(?:`|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\n\r]*|\/\*[\S\s]*?\*\/)/],["pln",/^(?:[^"'/`]|\/(?![*/]))+/]]),["go"]);

2
prettify/lang-hs.js Normal file
View File

@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t-\r ]+/,null,"\t\n \r "],["str",/^"(?:[^\n\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["str",/^'(?:[^\n\f\r'\\]|\\[^&])'?/,null,"'"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i,null,"0123456789"]],[["com",/^(?:--+[^\n\f\r]*|{-(?:[^-]|-+[^}-])*-})/],["kwd",/^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^\d'A-Za-z]|$)/,
null],["pln",/^(?:[A-Z][\w']*\.)*[A-Za-z][\w']*/],["pun",/^[^\d\t-\r "'A-Za-z]+/]]),["hs"]);

3
prettify/lang-lisp.js Normal file
View File

@ -0,0 +1,3 @@
var a=null;
PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \xa0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,a],
["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","scm"]);

2
prettify/lang-lua.js Normal file
View File

@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r Â\xa0"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$))/,null,"\"'"]],[["com",/^--(?:\[(=*)\[[\S\s]*?(?:]\1]|$)|[^\n\r]*)/],["str",/^\[(=*)\[[\S\s]*?(?:]\1]|$)/],["kwd",/^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,null],["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],
["pln",/^[_a-z]\w*/i],["pun",/^[^\w\t\n\r \xa0][^\w\t\n\r "'+=\xa0-]*/]]),["lua"]);

2
prettify/lang-ml.js Normal file
View File

@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r Â\xa0"],["com",/^#(?:if[\t\n\r \xa0]+(?:[$_a-z][\w']*|``[^\t\n\r`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])(?:'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\n\r]*|\(\*[\S\s]*?\*\))/],["kwd",/^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/],
["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],["pln",/^(?:[_a-z][\w']*[!#?]?|``[^\t\n\r`]*(?:``|$))/i],["pun",/^[^\w\t\n\r "'\xa0]+/]]),["fs","ml"]);

4
prettify/lang-n.js Normal file
View File

@ -0,0 +1,4 @@
var a=null;
PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:'(?:[^\n\r'\\]|\\.)*'|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,a,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,a,"#"],["pln",/^\s+/,a," \r\n\t\xa0"]],[["str",/^@"(?:[^"]|"")*(?:"|$)/,a],["str",/^<#[^#>]*(?:#>|$)/,a],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,a],["com",/^\/\/[^\n\r]*/,a],["com",/^\/\*[\S\s]*?(?:\*\/|$)/,
a],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/,
a],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,a],["lit",/^@[$_a-z][\w$@]*/i,a],["typ",/^@[A-Z]+[a-z][\w$@]*/,a],["pln",/^'?[$_a-z][\w$@]*/i,a],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,a,"0123456789"],["pun",/^.[^\s\w"-$'./@`]*/,a]]),["n","nemerle"]);

1
prettify/lang-proto.js Normal file
View File

@ -0,0 +1 @@
PR.registerLangHandler(PR.sourceDecorator({keywords:"bytes,default,double,enum,extend,extensions,false,group,import,max,message,option,optional,package,repeated,required,returns,rpc,service,syntax,to,true",types:/^(bool|(double|s?fixed|[su]?int)(32|64)|float|string)\b/,cStyleComments:!0}),["proto"]);

2
prettify/lang-scala.js Normal file
View File

@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r Â\xa0"],["str",/^"(?:""(?:""?(?!")|[^"\\]|\\.)*"{0,3}|(?:[^\n\r"\\]|\\.)*"?)/,null,'"'],["lit",/^`(?:[^\n\r\\`]|\\.)*`?/,null,"`"],["pun",/^[!#%&(--:-@[-^{-~]+/,null,"!#%&()*+,-:;<=>?@[\\]^{|}~"]],[["str",/^'(?:[^\n\r'\\]|\\(?:'|[^\n\r']+))'/],["lit",/^'[$A-Z_a-z][\w$]*(?![\w$'])/],["kwd",/^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\b/],
["lit",/^(?:true|false|null|this)\b/],["lit",/^(?:0(?:[0-7]+|x[\da-f]+)l?|(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:e[+-]?\d+)?f?|l?)|\\.\d+(?:e[+-]?\d+)?f?)/i],["typ",/^[$_]*[A-Z][\d$A-Z_]*[a-z][\w$]*/],["pln",/^[$A-Z_a-z][\w$]*/],["com",/^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/],["pun",/^(?:\.+|\/)/]]),["scala"]);

2
prettify/lang-sql.js Normal file
View File

@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r Â\xa0"],["str",/^(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/,null,"\"'"]],[["com",/^(?:--[^\n\r]*|\/\*[\S\s]*?(?:\*\/|$))/],["kwd",/^(?:add|all|alter|and|any|as|asc|authorization|backup|begin|between|break|browse|bulk|by|cascade|case|check|checkpoint|close|clustered|coalesce|collate|column|commit|compute|constraint|contains|containstable|continue|convert|create|cross|current|current_date|current_time|current_timestamp|current_user|cursor|database|dbcc|deallocate|declare|default|delete|deny|desc|disk|distinct|distributed|double|drop|dummy|dump|else|end|errlvl|escape|except|exec|execute|exists|exit|fetch|file|fillfactor|for|foreign|freetext|freetexttable|from|full|function|goto|grant|group|having|holdlock|identity|identitycol|identity_insert|if|in|index|inner|insert|intersect|into|is|join|key|kill|left|like|lineno|load|match|merge|national|nocheck|nonclustered|not|null|nullif|of|off|offsets|on|open|opendatasource|openquery|openrowset|openxml|option|or|order|outer|over|percent|plan|precision|primary|print|proc|procedure|public|raiserror|read|readtext|reconfigure|references|replication|restore|restrict|return|revoke|right|rollback|rowcount|rowguidcol|rule|save|schema|select|session_user|set|setuser|shutdown|some|statistics|system_user|table|textsize|then|to|top|tran|transaction|trigger|truncate|tsequal|union|unique|update|updatetext|use|user|using|values|varying|view|waitfor|when|where|while|with|writetext)(?=[^\w-]|$)/i,
null],["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],["pln",/^[_a-z][\w-]*/i],["pun",/^[^\w\t\n\r "'\xa0][^\w\t\n\r "'+\xa0-]*/]]),["sql"]);

1
prettify/lang-tex.js Normal file
View File

@ -0,0 +1 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r Â\xa0"],["com",/^%[^\n\r]*/,null,"%"]],[["kwd",/^\\[@-Za-z]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[()=[\]{}]+/]]),["latex","tex"]);

2
prettify/lang-vb.js Normal file
View File

@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0\u2028\u2029]+/,null,"\t\n\r Â\xa0

"],["str",/^(?:["\u201c\u201d](?:[^"\u201c\u201d]|["\u201c\u201d]{2})(?:["\u201c\u201d]c|$)|["\u201c\u201d](?:[^"\u201c\u201d]|["\u201c\u201d]{2})*(?:["\u201c\u201d]|$))/i,null,'"“â€<C3A2>'],["com",/^['\u2018\u2019].*/,null,"'‘’"]],[["kwd",/^(?:addhandler|addressof|alias|and|andalso|ansi|as|assembly|auto|boolean|byref|byte|byval|call|case|catch|cbool|cbyte|cchar|cdate|cdbl|cdec|char|cint|class|clng|cobj|const|cshort|csng|cstr|ctype|date|decimal|declare|default|delegate|dim|directcast|do|double|each|else|elseif|end|endif|enum|erase|error|event|exit|finally|for|friend|function|get|gettype|gosub|goto|handles|if|implements|imports|in|inherits|integer|interface|is|let|lib|like|long|loop|me|mod|module|mustinherit|mustoverride|mybase|myclass|namespace|new|next|not|notinheritable|notoverridable|object|on|option|optional|or|orelse|overloads|overridable|overrides|paramarray|preserve|private|property|protected|public|raiseevent|readonly|redim|removehandler|resume|return|select|set|shadows|shared|short|single|static|step|stop|string|structure|sub|synclock|then|throw|to|try|typeof|unicode|until|variant|wend|when|while|with|withevents|writeonly|xor|endif|gosub|let|variant|wend)\b/i,
null],["com",/^rem.*/i],["lit",/^(?:true\b|false\b|nothing\b|\d+(?:e[+-]?\d+[dfr]?|[dfilrs])?|(?:&h[\da-f]+|&o[0-7]+)[ils]?|\d*\.\d+(?:e[+-]?\d+)?[dfr]?|#\s+(?:\d+[/-]\d+[/-]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:am|pm))?)?|\d+:\d+(?::\d+)?(\s*(?:am|pm))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*|\[(?:[a-z]|_\w)\w*])/i],["pun",/^[^\w\t\n\r "'[\]\xa0\u2018\u2019\u201c\u201d\u2028\u2029]+/],["pun",/^(?:\[|])/]]),["vb","vbs"]);

3
prettify/lang-vhdl.js Normal file
View File

@ -0,0 +1,3 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r Â\xa0"]],[["str",/^(?:[box]?"(?:[^"]|"")*"|'.')/i],["com",/^--[^\n\r]*/],["kwd",/^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i,
null],["typ",/^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i,null],["typ",/^'(?:active|ascending|base|delayed|driving|driving_value|event|high|image|instance_name|last_active|last_event|last_value|left|leftof|length|low|path_name|pos|pred|quiet|range|reverse_range|right|rightof|simple_name|stable|succ|transaction|val|value)(?=[^\w-]|$)/i,null],["lit",/^\d+(?:_\d+)*(?:#[\w.\\]+#(?:[+-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:e[+-]?\d+(?:_\d+)*)?)/i],
["pln",/^(?:[a-z]\w*|\\[^\\]*\\)/i],["pun",/^[^\w\t\n\r "'\xa0][^\w\t\n\r "'\xa0-]*/]]),["vhdl","vhd"]);

2
prettify/lang-wiki.js Normal file
View File

@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\d\t a-gi-z\xa0]+/,null,"\t Â\xa0abcdefgijklmnopqrstuvwxyz0123456789"],["pun",/^[*=[\]^~]+/,null,"=*~^[]"]],[["lang-wiki.meta",/(?:^^|\r\n?|\n)(#[a-z]+)\b/],["lit",/^[A-Z][a-z][\da-z]+[A-Z][a-z][^\W_]+\b/],["lang-",/^{{{([\S\s]+?)}}}/],["lang-",/^`([^\n\r`]+)`/],["str",/^https?:\/\/[^\s#/?]*(?:\/[^\s#?]*)?(?:\?[^\s#]*)?(?:#\S*)?/i],["pln",/^(?:\r\n|[\S\s])[^\n\r#*=A-[^`h{~]*/]]),["wiki"]);
PR.registerLangHandler(PR.createSimpleLexer([["kwd",/^#[a-z]+/i,null,"#"]],[]),["wiki.meta"]);

3
prettify/lang-xq.js Normal file

File diff suppressed because one or more lines are too long

2
prettify/lang-yaml.js Normal file
View File

@ -0,0 +1,2 @@
var a=null;
PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:>?|]+/,a,":|>?"],["dec",/^%(?:YAML|TAG)[^\n\r#]+/,a,"%"],["typ",/^&\S+/,a,"&"],["typ",/^!\S*/,a,"!"],["str",/^"(?:[^"\\]|\\.)*(?:"|$)/,a,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,a,"'"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^\s+/,a," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\n\r]|$)/],["pun",/^-/],["kwd",/^\w+:[\n\r ]/],["pln",/^\w+/]]),["yaml","yml"]);

1
prettify/prettify.css Normal file
View File

@ -0,0 +1 @@
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}

28
prettify/prettify.js Normal file
View File

@ -0,0 +1,28 @@
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

View File

@ -0,0 +1,52 @@
/* Pretty printing styles. Used with prettify.js. */
/* Vim sunburst theme by David Leibovic */
pre .str, code .str { color: #65B042; } /* string - green */
pre .kwd, code .kwd { color: #E28964; } /* keyword - dark pink */
pre .com, code .com { color: #AEAEAE; font-style: italic; } /* comment - gray */
pre .typ, code .typ { color: #89bdff; } /* type - light blue */
pre .lit, code .lit { color: #3387CC; } /* literal - blue */
pre .pun, code .pun { color: #fff; } /* punctuation - white */
pre .pln, code .pln { color: #fff; } /* plaintext - white */
pre .tag, code .tag { color: #89bdff; } /* html/xml tag - light blue */
pre .atn, code .atn { color: #bdb76b; } /* html/xml attribute name - khaki */
pre .atv, code .atv { color: #65B042; } /* html/xml attribute value - green */
pre .dec, code .dec { color: #3387CC; } /* decimal - blue */
pre.prettyprint, code.prettyprint {
background-color: #000;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
-ms-border-radius: 8px;
-o-border-radius: 8px;
border-radius: 8px;
}
pre.prettyprint {
width: 95%;
margin: 1em auto;
padding: 1em;
white-space: pre-wrap;
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE; } /* IE indents via margin-left */
li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none }
/* Alternate shading for lines */
li.L1,li.L3,li.L5,li.L7,li.L9 { }
@media print {
pre .str, code .str { color: #060; }
pre .kwd, code .kwd { color: #006; font-weight: bold; }
pre .com, code .com { color: #600; font-style: italic; }
pre .typ, code .typ { color: #404; font-weight: bold; }
pre .lit, code .lit { color: #044; }
pre .pun, code .pun { color: #440; }
pre .pln, code .pln { color: #000; }
pre .tag, code .tag { color: #006; font-weight: bold; }
pre .atn, code .atn { color: #404; }
pre .atv, code .atv { color: #060; }
}

181
screen.css Normal file
View File

@ -0,0 +1,181 @@
@charset "utf-8";
body {
margin: 0;
background-color: #D0D0D0;
font-family: "Helvetica,Arial,FreeSans";
color: #000000;
}
img { border:0; }
#container {
margin: 0 auto;
width: 700px;
padding: 20px;
background-color: #FFFFFF;
border-left: 1px solid #999999;
border-right: 1px solid #999999;
}
h1 {
font-size: 3.8em;
color: #2c879b;
margin-bottom: 3px;
}
h1 > .small {
font-size: 0.4em;
}
h1 a {
text-decoration: none
}
h2 {
font-size: 1.5em;
color: #2c879b;
border-bottom: 1px dotted #2c879b;
}
h3 {
text-align: center;
color: #2c879b;
}
a {
color: #2c879b;
}
.description {
font-size: 1.2em;
margin-bottom: 30px;
margin-top: 30px;
font-style: italic;
}
/*
pre {
background: #000;
color: #fff;
padding: 15px;
}
*/
hr {
border: 0;
width: 80%;
border-bottom: 1px solid #aaa;
}
ul.plain-list {
list-style-type:none;
margin:0;
padding:0;
}
ul.plain-list > li {
list-style-type:none;
margin:0;
padding:0;
}
#download {
float: right;
}
#github-forkme {
position: absolute;
top: 0;
right: 0;
}
#github-watch {
position: fixed;
bottom: 10px;
right: 10px;
}
#container .footer { text-align:center; padding-top:30px; font-style: italic; }
.menu { font-size: 0; }
.menu > li {
list-style-type: none;
display: inline-block;
font-size: 15px;
}
.menu > li + li {
margin-left: 5px;
}
.menu > li > a {
color: white;
font-weight: bold;
background-color: #666;
text-decoration: none;
display: block;
padding: 2px 4px 2px 4px;
}
.menu > li.active > a {
background-color: #2C879B;
}
.menu > li > a:hover {
background-color: #111;
}
#demo-list > li.current {
font-style: italic;
}
#demo-list > li.current:after {
content: "« currently viewing";
color: #AAA;
display: inline-block;
margin-left: 20px;
}
/* hide whitespace between inline-block elements */
.inline-spaces { font-size: 0; }
.inline-spaces > * { font-size: 11px; }
/* demo trigger boxes */
.box {
color: #EEE;
background: #666;
font-weight: bold;
padding: 20px;
text-align: center;
font-size: 20px;
margin: 5px 0;
}
.box:hover {
background: #777;
}
.box > * {
display:block;
}
.menu-injected { background-color: #C87958; }
.box.context-menu-disabled { background-color: red; }
.ascii-art .line {
color: #999;
}
.ascii-art .label {
color: #2C879B;
font-weight: bold;
}
.note {
background-color: #EEE;
padding: 10px;
margin: -10px;
}
.note::before {
content: "NOTE: ";
font-weight: bold;
}
pre + .note,
.note + .note {
margin-top: 10px;
}

39
screen.js Normal file
View File

@ -0,0 +1,39 @@
(function($, undefined){
$(function() {
if (!window.prettyPrint) {
return;
}
$('.showcase').each(function(){
var $this = $(that || this),
text, nodeName, lang, that;
if ($this.data('showcaseImport')) {
$this = $($this.data('showcaseImport'));
that = $this.get(0);
}
nodeName = (that || this).nodeName.toLowerCase();
lang = nodeName == 'script'
? 'js'
: (nodeName == 'style' ? 'css' : 'html');
if (lang == 'html') {
text = $('<div></div>').append($this.clone()).html();
} else {
text = $this.text();
}
$('<pre class="prettyprint lang-'+ lang +'"></pre>')
.text(text)
.insertBefore(this);
that && $(this).remove();
});
prettyPrint();
});
})(jQuery);

185
src/IPv6.js Normal file
View File

@ -0,0 +1,185 @@
/*!
* URI.js - Mutating URLs
* IPv6 Support
*
* Version: 1.18.2
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
*/
(function (root, factory) {
'use strict';
// https://github.com/umdjs/umd/blob/master/returnExports.js
if (typeof exports === 'object') {
// Node
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else {
// Browser globals (root is window)
root.IPv6 = factory(root);
}
}(this, function (root) {
'use strict';
/*
var _in = "fe80:0000:0000:0000:0204:61ff:fe9d:f156";
var _out = IPv6.best(_in);
var _expected = "fe80::204:61ff:fe9d:f156";
console.log(_in, _out, _expected, _out === _expected);
*/
// save current IPv6 variable, if any
var _IPv6 = root && root.IPv6;
function bestPresentation(address) {
// based on:
// Javascript to test an IPv6 address for proper format, and to
// present the "best text representation" according to IETF Draft RFC at
// http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04
// 8 Feb 2010 Rich Brown, Dartware, LLC
// Please feel free to use this code as long as you provide a link to
// http://www.intermapper.com
// http://intermapper.com/support/tools/IPV6-Validator.aspx
// http://download.dartware.com/thirdparty/ipv6validator.js
var _address = address.toLowerCase();
var segments = _address.split(':');
var length = segments.length;
var total = 8;
// trim colons (:: or ::a:b:c… or …a:b:c::)
if (segments[0] === '' && segments[1] === '' && segments[2] === '') {
// must have been ::
// remove first two items
segments.shift();
segments.shift();
} else if (segments[0] === '' && segments[1] === '') {
// must have been ::xxxx
// remove the first item
segments.shift();
} else if (segments[length - 1] === '' && segments[length - 2] === '') {
// must have been xxxx::
segments.pop();
}
length = segments.length;
// adjust total segments for IPv4 trailer
if (segments[length - 1].indexOf('.') !== -1) {
// found a "." which means IPv4
total = 7;
}
// fill empty segments them with "0000"
var pos;
for (pos = 0; pos < length; pos++) {
if (segments[pos] === '') {
break;
}
}
if (pos < total) {
segments.splice(pos, 1, '0000');
while (segments.length < total) {
segments.splice(pos, 0, '0000');
}
}
// strip leading zeros
var _segments;
for (var i = 0; i < total; i++) {
_segments = segments[i].split('');
for (var j = 0; j < 3 ; j++) {
if (_segments[0] === '0' && _segments.length > 1) {
_segments.splice(0,1);
} else {
break;
}
}
segments[i] = _segments.join('');
}
// find longest sequence of zeroes and coalesce them into one segment
var best = -1;
var _best = 0;
var _current = 0;
var current = -1;
var inzeroes = false;
// i; already declared
for (i = 0; i < total; i++) {
if (inzeroes) {
if (segments[i] === '0') {
_current += 1;
} else {
inzeroes = false;
if (_current > _best) {
best = current;
_best = _current;
}
}
} else {
if (segments[i] === '0') {
inzeroes = true;
current = i;
_current = 1;
}
}
}
if (_current > _best) {
best = current;
_best = _current;
}
if (_best > 1) {
segments.splice(best, _best, '');
}
length = segments.length;
// assemble remaining segments
var result = '';
if (segments[0] === '') {
result = ':';
}
for (i = 0; i < length; i++) {
result += segments[i];
if (i === length - 1) {
break;
}
result += ':';
}
if (segments[length - 1] === '') {
result += ':';
}
return result;
}
function noConflict() {
/*jshint validthis: true */
if (root.IPv6 === this) {
root.IPv6 = _IPv6;
}
return this;
}
return {
best: bestPresentation,
noConflict: noConflict
};
}));

240
src/SecondLevelDomains.js Normal file
View File

@ -0,0 +1,240 @@
/*!
* URI.js - Mutating URLs
* Second Level Domain (SLD) Support
*
* Version: 1.18.2
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
*/
(function (root, factory) {
'use strict';
// https://github.com/umdjs/umd/blob/master/returnExports.js
if (typeof exports === 'object') {
// Node
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else {
// Browser globals (root is window)
root.SecondLevelDomains = factory(root);
}
}(this, function (root) {
'use strict';
// save current SecondLevelDomains variable, if any
var _SecondLevelDomains = root && root.SecondLevelDomains;
var SLD = {
// list of known Second Level Domains
// converted list of SLDs from https://github.com/gavingmiller/second-level-domains
// ----
// publicsuffix.org is more current and actually used by a couple of browsers internally.
// downside is it also contains domains like "dyndns.org" - which is fine for the security
// issues browser have to deal with (SOP for cookies, etc) - but is way overboard for URI.js
// ----
list: {
'ac':' com gov mil net org ',
'ae':' ac co gov mil name net org pro sch ',
'af':' com edu gov net org ',
'al':' com edu gov mil net org ',
'ao':' co ed gv it og pb ',
'ar':' com edu gob gov int mil net org tur ',
'at':' ac co gv or ',
'au':' asn com csiro edu gov id net org ',
'ba':' co com edu gov mil net org rs unbi unmo unsa untz unze ',
'bb':' biz co com edu gov info net org store tv ',
'bh':' biz cc com edu gov info net org ',
'bn':' com edu gov net org ',
'bo':' com edu gob gov int mil net org tv ',
'br':' adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ',
'bs':' com edu gov net org ',
'bz':' du et om ov rg ',
'ca':' ab bc mb nb nf nl ns nt nu on pe qc sk yk ',
'ck':' biz co edu gen gov info net org ',
'cn':' ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ',
'co':' com edu gov mil net nom org ',
'cr':' ac c co ed fi go or sa ',
'cy':' ac biz com ekloges gov ltd name net org parliament press pro tm ',
'do':' art com edu gob gov mil net org sld web ',
'dz':' art asso com edu gov net org pol ',
'ec':' com edu fin gov info med mil net org pro ',
'eg':' com edu eun gov mil name net org sci ',
'er':' com edu gov ind mil net org rochest w ',
'es':' com edu gob nom org ',
'et':' biz com edu gov info name net org ',
'fj':' ac biz com info mil name net org pro ',
'fk':' ac co gov net nom org ',
'fr':' asso com f gouv nom prd presse tm ',
'gg':' co net org ',
'gh':' com edu gov mil org ',
'gn':' ac com gov net org ',
'gr':' com edu gov mil net org ',
'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 ',
'iq':' com edu gov i mil net org ',
'ir':' ac co dnssec gov i id net org sch ',
'it':' edu gov ',
'je':' co net org ',
'jo':' com edu gov mil name net org sch ',
'jp':' ac ad co ed go gr lg ne or ',
'ke':' ac co go info me mobi ne or sc ',
'kh':' com edu gov mil net org per ',
'ki':' biz com de edu gov info mob net org tel ',
'km':' asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ',
'kn':' edu gov net org ',
'kr':' ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ',
'kw':' com edu gov net org ',
'ky':' com edu gov net org ',
'kz':' com edu gov mil net org ',
'lb':' com edu gov net org ',
'lk':' assn com edu gov grp hotel int ltd net ngo org sch soc web ',
'lr':' com edu gov net org ',
'lv':' asn com conf edu gov id mil net org ',
'ly':' com edu gov id med net org plc sch ',
'ma':' ac co gov m net org press ',
'mc':' asso tm ',
'me':' ac co edu gov its net org priv ',
'mg':' com edu gov mil nom org prd tm ',
'mk':' com edu gov inf name net org pro ',
'ml':' com edu gov net org presse ',
'mn':' edu gov org ',
'mo':' com edu gov net org ',
'mt':' com edu gov net org ',
'mv':' aero biz com coop edu gov info int mil museum name net org pro ',
'mw':' ac co com coop edu gov int museum net org ',
'mx':' com edu gob net org ',
'my':' com edu gov mil name net org sch ',
'nf':' arts com firm info net other per rec store web ',
'ng':' biz com edu gov mil mobi name net org sch ',
'ni':' ac co com edu gob mil net nom org ',
'np':' com edu gov mil net org ',
'nr':' biz com edu gov info net org ',
'om':' ac biz co com edu gov med mil museum net org pro sch ',
'pe':' com edu gob mil net nom org sld ',
'ph':' com edu gov i mil net ngo org ',
'pk':' biz com edu fam gob gok gon gop gos gov net org web ',
'pl':' art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ',
'pr':' ac biz com edu est gov info isla name net org pro prof ',
'ps':' com edu gov net org plo sec ',
'pw':' belau co ed go ne or ',
'ro':' arts com firm info nom nt org rec store tm www ',
'rs':' ac co edu gov in org ',
'sb':' com edu gov net org ',
'sc':' com edu gov net org ',
'sh':' co com edu gov net nom org ',
'sl':' com edu gov net org ',
'st':' co com consulado edu embaixada gov mil net org principe saotome store ',
'sv':' com edu gob org red ',
'sz':' ac co org ',
'tr':' av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ',
'tt':' aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ',
'tw':' club com ebiz edu game gov idv mil net org ',
'mu':' ac co com gov net or org ',
'mz':' ac co edu gov org ',
'na':' co com ',
'nz':' ac co cri geek gen govt health iwi maori mil net org parliament school ',
'pa':' abo ac com edu gob ing med net nom org sld ',
'pt':' com edu gov int net nome org publ ',
'py':' com edu gov mil net org ',
'qa':' com edu gov mil net org ',
're':' asso com nom ',
'ru':' ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ',
'rw':' ac co com edu gouv gov int mil net ',
'sa':' com edu gov med net org pub sch ',
'sd':' com edu gov info med net org tv ',
'se':' a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ',
'sg':' com edu gov idn net org per ',
'sn':' art com edu gouv org perso univ ',
'sy':' com edu gov mil net news org ',
'th':' ac co go in mi net or ',
'tj':' ac biz co com edu go gov info int mil name net nic org test web ',
'tn':' agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ',
'tz':' ac co go ne or ',
'ua':' biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ',
'ug':' ac co go ne or org sc ',
'uk':' ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ',
'us':' dni fed isa kids nsn ',
'uy':' com edu gub mil net org ',
've':' co com edu gob info mil net org web ',
'vi':' co com k12 net org ',
'vn':' ac biz com edu gov health info int name net org pro ',
'ye':' co com gov ltd me net org plc ',
'yu':' ac co edu gov org ',
'za':' ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ',
'zm':' ac co com edu gov net org sch '
},
// gorhill 2013-10-25: Using indexOf() instead Regexp(). Significant boost
// in both performance and memory footprint. No initialization required.
// http://jsperf.com/uri-js-sld-regex-vs-binary-search/4
// Following methods use lastIndexOf() rather than array.split() in order
// to avoid any memory allocations.
has: function(domain) {
var tldOffset = domain.lastIndexOf('.');
if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {
return false;
}
var sldOffset = domain.lastIndexOf('.', tldOffset-1);
if (sldOffset <= 0 || sldOffset >= (tldOffset-1)) {
return false;
}
var sldList = SLD.list[domain.slice(tldOffset+1)];
if (!sldList) {
return false;
}
return sldList.indexOf(' ' + domain.slice(sldOffset+1, tldOffset) + ' ') >= 0;
},
is: function(domain) {
var tldOffset = domain.lastIndexOf('.');
if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {
return false;
}
var sldOffset = domain.lastIndexOf('.', tldOffset-1);
if (sldOffset >= 0) {
return false;
}
var sldList = SLD.list[domain.slice(tldOffset+1)];
if (!sldList) {
return false;
}
return sldList.indexOf(' ' + domain.slice(0, tldOffset) + ' ') >= 0;
},
get: function(domain) {
var tldOffset = domain.lastIndexOf('.');
if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {
return null;
}
var sldOffset = domain.lastIndexOf('.', tldOffset-1);
if (sldOffset <= 0 || sldOffset >= (tldOffset-1)) {
return null;
}
var sldList = SLD.list[domain.slice(tldOffset+1)];
if (!sldList) {
return null;
}
if (sldList.indexOf(' ' + domain.slice(sldOffset+1, tldOffset) + ' ') < 0) {
return null;
}
return domain.slice(sldOffset+1);
},
noConflict: function(){
if (root.SecondLevelDomains === this) {
root.SecondLevelDomains = _SecondLevelDomains;
}
return this;
}
};
return SLD;
}));

104
src/URI.fragmentQuery.js Normal file
View File

@ -0,0 +1,104 @@
/*
* Extending URI.js for fragment abuse
*/
// --------------------------------------------------------------------------------
// EXAMPLE: storing application/x-www-form-urlencoded data in the fragment
// possibly helpful for Google's hashbangs
// see http://code.google.com/web/ajaxcrawling/
// --------------------------------------------------------------------------------
// Note: make sure this is the last file loaded!
// USAGE:
// var uri = URI("http://example.org/#?foo=bar");
// uri.fragment(true) === {foo: "bar"};
// uri.fragment({bar: "foo"});
// uri.toString() === "http://example.org/#?bar=foo";
// uri.addFragment("name", "value");
// uri.toString() === "http://example.org/#?bar=foo&name=value";
// uri.removeFragment("name");
// uri.toString() === "http://example.org/#?bar=foo";
(function (root, factory) {
'use strict';
// https://github.com/umdjs/umd/blob/master/returnExports.js
if (typeof exports === 'object') {
// Node
module.exports = factory(require('./URI'));
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['./URI'], factory);
} else {
// Browser globals (root is window)
factory(root.URI);
}
}(this, function (URI) {
'use strict';
var p = URI.prototype;
// old fragment handler we need to wrap
var f = p.fragment;
// make fragmentPrefix configurable
URI.fragmentPrefix = '?';
var _parts = URI._parts;
URI._parts = function() {
var parts = _parts();
parts.fragmentPrefix = URI.fragmentPrefix;
return parts;
};
p.fragmentPrefix = function(v) {
this._parts.fragmentPrefix = v;
return this;
};
// add fragment(true) and fragment({key: value}) signatures
p.fragment = function(v, build) {
var prefix = this._parts.fragmentPrefix;
var fragment = this._parts.fragment || '';
if (v === true) {
if (fragment.substring(0, prefix.length) !== prefix) {
return {};
}
return URI.parseQuery(fragment.substring(prefix.length));
} else if (v !== undefined && typeof v !== 'string') {
this._parts.fragment = prefix + URI.buildQuery(v);
this.build(!build);
return this;
} else {
return f.call(this, v, build);
}
};
p.addFragment = function(name, value, build) {
var prefix = this._parts.fragmentPrefix;
var data = URI.parseQuery((this._parts.fragment || '').substring(prefix.length));
URI.addQuery(data, name, value);
this._parts.fragment = prefix + URI.buildQuery(data);
if (typeof name !== 'string') {
build = value;
}
this.build(!build);
return this;
};
p.removeFragment = function(name, value, build) {
var prefix = this._parts.fragmentPrefix;
var data = URI.parseQuery((this._parts.fragment || '').substring(prefix.length));
URI.removeQuery(data, name, value);
this._parts.fragment = prefix + URI.buildQuery(data);
if (typeof name !== 'string') {
build = value;
}
this.build(!build);
return this;
};
p.addHash = p.addFragment;
p.removeHash = p.removeFragment;
// extending existing object rather than defining something new
return URI;
}));

97
src/URI.fragmentURI.js Normal file
View File

@ -0,0 +1,97 @@
/*
* Extending URI.js for fragment abuse
*/
// --------------------------------------------------------------------------------
// EXAMPLE: storing a relative URL in the fragment ("FragmentURI")
// possibly helpful when working with backbone.js or sammy.js
// inspired by https://github.com/medialize/URI.js/pull/2
// --------------------------------------------------------------------------------
// Note: make sure this is the last file loaded!
// USAGE:
// var uri = URI("http://example.org/#!/foo/bar/baz.html");
// var furi = uri.fragment(true);
// furi.pathname() === '/foo/bar/baz.html';
// furi.pathname('/hello.html');
// uri.toString() === "http://example.org/#!/hello.html"
(function (root, factory) {
'use strict';
// https://github.com/umdjs/umd/blob/master/returnExports.js
if (typeof exports === 'object') {
// Node
module.exports = factory(require('./URI'));
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['./URI'], factory);
} else {
// Browser globals (root is window)
factory(root.URI);
}
}(this, function (URI) {
'use strict';
var p = URI.prototype;
// old handlers we need to wrap
var f = p.fragment;
var b = p.build;
// make fragmentPrefix configurable
URI.fragmentPrefix = '!';
var _parts = URI._parts;
URI._parts = function() {
var parts = _parts();
parts.fragmentPrefix = URI.fragmentPrefix;
return parts;
};
p.fragmentPrefix = function(v) {
this._parts.fragmentPrefix = v;
return this;
};
// add fragment(true) and fragment(URI) signatures
p.fragment = function(v, build) {
var prefix = this._parts.fragmentPrefix;
var fragment = this._parts.fragment || '';
var furi;
if (v === true) {
if (fragment.substring(0, prefix.length) !== prefix) {
furi = URI('');
} else {
furi = new URI(fragment.substring(prefix.length));
}
this._fragmentURI = furi;
furi._parentURI = this;
return furi;
} else if (v !== undefined && typeof v !== 'string') {
this._fragmentURI = v;
v._parentURI = v;
this._parts.fragment = prefix + v.toString();
this.build(!build);
return this;
} else if (typeof v === 'string') {
this._fragmentURI = undefined;
}
return f.call(this, v, build);
};
// make .build() of the actual URI aware of the FragmentURI
p.build = function(deferBuild) {
var t = b.call(this, deferBuild);
if (deferBuild !== false && this._parentURI) {
// update the parent
this._parentURI.fragment(this);
}
return t;
};
// extending existing object rather than defining something new
return URI;
}));

2218
src/URI.js Normal file

File diff suppressed because it is too large Load Diff

89
src/URI.min.js vendored Normal file
View File

@ -0,0 +1,89 @@
/*! URI.js v1.18.2 http://medialize.github.io/URI.js/ */
/* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js */
(function(f,h){"object"===typeof exports?module.exports=h():"function"===typeof define&&define.amd?define(h):f.IPv6=h(f)})(this,function(f){var h=f&&f.IPv6;return{best:function(g){g=g.toLowerCase().split(":");var n=g.length,b=8;""===g[0]&&""===g[1]&&""===g[2]?(g.shift(),g.shift()):""===g[0]&&""===g[1]?g.shift():""===g[n-1]&&""===g[n-2]&&g.pop();n=g.length;-1!==g[n-1].indexOf(".")&&(b=7);var k;for(k=0;k<n&&""!==g[k];k++);if(k<b)for(g.splice(k,1,"0000");g.length<b;)g.splice(k,0,"0000");for(k=0;k<b;k++){for(var n=
g[k].split(""),f=0;3>f;f++)if("0"===n[0]&&1<n.length)n.splice(0,1);else break;g[k]=n.join("")}var n=-1,h=f=0,l=-1,q=!1;for(k=0;k<b;k++)q?"0"===g[k]?h+=1:(q=!1,h>f&&(n=l,f=h)):"0"===g[k]&&(q=!0,l=k,h=1);h>f&&(n=l,f=h);1<f&&g.splice(n,f,"");n=g.length;b="";""===g[0]&&(b=":");for(k=0;k<n;k++){b+=g[k];if(k===n-1)break;b+=":"}""===g[n-1]&&(b+=":");return b},noConflict:function(){f.IPv6===this&&(f.IPv6=h);return this}}});
(function(f){function h(b){throw new RangeError(e[b]);}function g(b,e){for(var g=b.length,l=[];g--;)l[g]=e(b[g]);return l}function n(b,e){var l=b.split("@"),f="";1<l.length&&(f=l[0]+"@",b=l[1]);b=b.replace(x,".");l=b.split(".");l=g(l,e).join(".");return f+l}function b(b){for(var e=[],l=0,g=b.length,f,a;l<g;)f=b.charCodeAt(l++),55296<=f&&56319>=f&&l<g?(a=b.charCodeAt(l++),56320==(a&64512)?e.push(((f&1023)<<10)+(a&1023)+65536):(e.push(f),l--)):e.push(f);return e}function k(b){return g(b,function(b){var e=
"";65535<b&&(b-=65536,e+=u(b>>>10&1023|55296),b=56320|b&1023);return e+=u(b)}).join("")}function A(b,e){return b+22+75*(26>b)-((0!=e)<<5)}function y(b,e,l){var g=0;b=l?p(b/700):b>>1;for(b+=p(b/e);455<b;g+=36)b=p(b/35);return p(g+36*b/(b+38))}function l(b){var e=[],l=b.length,g,f=0,a=128,c=72,d,m,w,z,n;d=b.lastIndexOf("-");0>d&&(d=0);for(m=0;m<d;++m)128<=b.charCodeAt(m)&&h("not-basic"),e.push(b.charCodeAt(m));for(d=0<d?d+1:0;d<l;){m=f;g=1;for(w=36;;w+=36){d>=l&&h("invalid-input");z=b.charCodeAt(d++);
z=10>z-48?z-22:26>z-65?z-65:26>z-97?z-97:36;(36<=z||z>p((2147483647-f)/g))&&h("overflow");f+=z*g;n=w<=c?1:w>=c+26?26:w-c;if(z<n)break;z=36-n;g>p(2147483647/z)&&h("overflow");g*=z}g=e.length+1;c=y(f-m,g,0==m);p(f/g)>2147483647-a&&h("overflow");a+=p(f/g);f%=g;e.splice(f++,0,a)}return k(e)}function q(e){var l,g,f,n,a,c,d,m,w,z=[],q,k,B;e=b(e);q=e.length;l=128;g=0;a=72;for(c=0;c<q;++c)w=e[c],128>w&&z.push(u(w));for((f=n=z.length)&&z.push("-");f<q;){d=2147483647;for(c=0;c<q;++c)w=e[c],w>=l&&w<d&&(d=w);
k=f+1;d-l>p((2147483647-g)/k)&&h("overflow");g+=(d-l)*k;l=d;for(c=0;c<q;++c)if(w=e[c],w<l&&2147483647<++g&&h("overflow"),w==l){m=g;for(d=36;;d+=36){w=d<=a?1:d>=a+26?26:d-a;if(m<w)break;B=m-w;m=36-w;z.push(u(A(w+B%m,0)));m=p(B/m)}z.push(u(A(m,0)));a=y(g,k,f==n);g=0;++f}++g;++l}return z.join("")}var B="object"==typeof exports&&exports&&!exports.nodeType&&exports,E="object"==typeof module&&module&&!module.nodeType&&module,D="object"==typeof global&&global;if(D.global===D||D.window===D||D.self===D)f=
D;var r,v=/^xn--/,t=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,e={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,u=String.fromCharCode,C;r={version:"1.3.2",ucs2:{decode:b,encode:k},decode:l,encode:q,toASCII:function(b){return n(b,function(b){return t.test(b)?"xn--"+q(b):b})},toUnicode:function(b){return n(b,function(b){return v.test(b)?l(b.slice(4).toLowerCase()):b})}};if("function"==
typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return r});else if(B&&E)if(module.exports==B)E.exports=r;else for(C in r)r.hasOwnProperty(C)&&(B[C]=r[C]);else f.punycode=r})(this);
(function(f,h){"object"===typeof exports?module.exports=h():"function"===typeof define&&define.amd?define(h):f.SecondLevelDomains=h(f)})(this,function(f){var h=f&&f.SecondLevelDomains,g={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",
bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",
ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",
es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",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 ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",
kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",
mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",
ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",
ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",
tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",
rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",
tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",
us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch "},has:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1)return!1;
var k=f.lastIndexOf(".",b-1);if(0>=k||k>=b-1)return!1;var h=g.list[f.slice(b+1)];return h?0<=h.indexOf(" "+f.slice(k+1,b)+" "):!1},is:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1||0<=f.lastIndexOf(".",b-1))return!1;var k=g.list[f.slice(b+1)];return k?0<=k.indexOf(" "+f.slice(0,b)+" "):!1},get:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1)return null;var k=f.lastIndexOf(".",b-1);if(0>=k||k>=b-1)return null;var h=g.list[f.slice(b+1)];return!h||0>h.indexOf(" "+f.slice(k+
1,b)+" ")?null:f.slice(k+1)},noConflict:function(){f.SecondLevelDomains===this&&(f.SecondLevelDomains=h);return this}};return g});
(function(f,h){"object"===typeof exports?module.exports=h(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],h):f.URI=h(f.punycode,f.IPv6,f.SecondLevelDomains,f)})(this,function(f,h,g,n){function b(a,c){var d=1<=arguments.length,m=2<=arguments.length;if(!(this instanceof b))return d?m?new b(a,c):new b(a):new b;if(void 0===a){if(d)throw new TypeError("undefined is not a valid argument for URI");
a="undefined"!==typeof location?location.href+"":""}this.href(a);return void 0!==c?this.absoluteTo(c):this}function k(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function A(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function y(a){return"Array"===A(a)}function l(a,c){var d={},b,w;if("RegExp"===A(c))d=null;else if(y(c))for(b=0,w=c.length;b<w;b++)d[c[b]]=!0;else d[c]=!0;b=0;for(w=a.length;b<w;b++)if(d&&void 0!==d[a[b]]||!d&&c.test(a[b]))a.splice(b,
1),w--,b--;return a}function q(a,c){var d,b;if(y(c)){d=0;for(b=c.length;d<b;d++)if(!q(a,c[d]))return!1;return!0}var w=A(c);d=0;for(b=a.length;d<b;d++)if("RegExp"===w){if("string"===typeof a[d]&&a[d].match(c))return!0}else if(a[d]===c)return!0;return!1}function B(a,c){if(!y(a)||!y(c)||a.length!==c.length)return!1;a.sort();c.sort();for(var d=0,b=a.length;d<b;d++)if(a[d]!==c[d])return!1;return!0}function E(a){return a.replace(/^\/+|\/+$/g,"")}function D(a){return escape(a)}function r(a){return encodeURIComponent(a).replace(/[!'()*]/g,
D).replace(/\*/g,"%2A")}function v(a){return function(c,d){if(void 0===c)return this._parts[a]||"";this._parts[a]=c||null;this.build(!d);return this}}function t(a,c){return function(d,b){if(void 0===d)return this._parts[a]||"";null!==d&&(d+="",d.charAt(0)===c&&(d=d.substring(1)));this._parts[a]=d;this.build(!b);return this}}var x=n&&n.URI;b.version="1.18.2";var e=b.prototype,p=Object.prototype.hasOwnProperty;b._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,
port:null,path:null,query:null,fragment:null,duplicateQueryParameters:b.duplicateQueryParameters,escapeQuerySpace:b.escapeQuerySpace}};b.duplicateQueryParameters=!1;b.escapeQuerySpace=!0;b.protocol_expression=/^[a-z][a-z0-9.+-]*$/i;b.idn_expression=/[^a-z0-9\.-]/i;b.punycode_expression=/(xn--)/i;b.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;b.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
b.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;b.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/};b.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};b.invalid_hostname_characters=
/[^a-zA-Z0-9\.-]/;b.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"};b.getDomAttribute=function(a){if(a&&a.nodeName){var c=a.nodeName.toLowerCase();return"input"===c&&"image"!==a.type?void 0:b.domAttributes[c]}};b.encode=r;b.decode=decodeURIComponent;b.iso8859=function(){b.encode=escape;b.decode=unescape};b.unicode=function(){b.encode=r;b.decode=
decodeURIComponent};b.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",",
"%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}};b.encodeQuery=function(a,c){var d=b.encode(a+"");void 0===c&&(c=b.escapeQuerySpace);return c?d.replace(/%20/g,"+"):d};b.decodeQuery=function(a,c){a+="";void 0===c&&(c=b.escapeQuerySpace);try{return b.decode(c?a.replace(/\+/g,
"%20"):a)}catch(d){return a}};var u={encode:"encode",decode:"decode"},C,F=function(a,c){return function(d){try{return b[c](d+"").replace(b.characters[a][c].expression,function(d){return b.characters[a][c].map[d]})}catch(m){return d}}};for(C in u)b[C+"PathSegment"]=F("pathname",u[C]),b[C+"UrnPathSegment"]=F("urnpath",u[C]);u=function(a,c,d){return function(m){var w;w=d?function(a){return b[c](b[d](a))}:b[c];m=(m+"").split(a);for(var e=0,f=m.length;e<f;e++)m[e]=w(m[e]);return m.join(a)}};b.decodePath=
u("/","decodePathSegment");b.decodeUrnPath=u(":","decodeUrnPathSegment");b.recodePath=u("/","encodePathSegment","decode");b.recodeUrnPath=u(":","encodeUrnPathSegment","decode");b.encodeReserved=F("reserved","encode");b.parse=function(a,c){var d;c||(c={});d=a.indexOf("#");-1<d&&(c.fragment=a.substring(d+1)||null,a=a.substring(0,d));d=a.indexOf("?");-1<d&&(c.query=a.substring(d+1)||null,a=a.substring(0,d));"//"===a.substring(0,2)?(c.protocol=null,a=a.substring(2),a=b.parseAuthority(a,c)):(d=a.indexOf(":"),
-1<d&&(c.protocol=a.substring(0,d)||null,c.protocol&&!c.protocol.match(b.protocol_expression)?c.protocol=void 0:"//"===a.substring(d+1,d+3)?(a=a.substring(d+3),a=b.parseAuthority(a,c)):(a=a.substring(d+1),c.urn=!0)));c.path=a;return c};b.parseHost=function(a,c){a=a.replace(/\\/g,"/");var d=a.indexOf("/"),b;-1===d&&(d=a.length);if("["===a.charAt(0))b=a.indexOf("]"),c.hostname=a.substring(1,b)||null,c.port=a.substring(b+2,d)||null,"/"===c.port&&(c.port=null);else{var e=a.indexOf(":");b=a.indexOf("/");
e=a.indexOf(":",e+1);-1!==e&&(-1===b||e<b)?(c.hostname=a.substring(0,d)||null,c.port=null):(b=a.substring(0,d).split(":"),c.hostname=b[0]||null,c.port=b[1]||null)}c.hostname&&"/"!==a.substring(d).charAt(0)&&(d++,a="/"+a);return a.substring(d)||"/"};b.parseAuthority=function(a,c){a=b.parseUserinfo(a,c);return b.parseHost(a,c)};b.parseUserinfo=function(a,c){var d=a.indexOf("/"),m=a.lastIndexOf("@",-1<d?d:a.length-1);-1<m&&(-1===d||m<d)?(d=a.substring(0,m).split(":"),c.username=d[0]?b.decode(d[0]):null,
d.shift(),c.password=d[0]?b.decode(d.join(":")):null,a=a.substring(m+1)):(c.username=null,c.password=null);return a};b.parseQuery=function(a,c){if(!a)return{};a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");if(!a)return{};for(var d={},m=a.split("&"),e=m.length,f,l,g=0;g<e;g++)if(f=m[g].split("="),l=b.decodeQuery(f.shift(),c),f=f.length?b.decodeQuery(f.join("="),c):null,p.call(d,l)){if("string"===typeof d[l]||null===d[l])d[l]=[d[l]];d[l].push(f)}else d[l]=f;return d};b.build=function(a){var c="";
a.protocol&&(c+=a.protocol+":");a.urn||!c&&!a.hostname||(c+="//");c+=b.buildAuthority(a)||"";"string"===typeof a.path&&("/"!==a.path.charAt(0)&&"string"===typeof a.hostname&&(c+="/"),c+=a.path);"string"===typeof a.query&&a.query&&(c+="?"+a.query);"string"===typeof a.fragment&&a.fragment&&(c+="#"+a.fragment);return c};b.buildHost=function(a){var c="";if(a.hostname)c=b.ip6_expression.test(a.hostname)?c+("["+a.hostname+"]"):c+a.hostname;else return"";a.port&&(c+=":"+a.port);return c};b.buildAuthority=
function(a){return b.buildUserinfo(a)+b.buildHost(a)};b.buildUserinfo=function(a){var c="";a.username&&(c+=b.encode(a.username));a.password&&(c+=":"+b.encode(a.password));c&&(c+="@");return c};b.buildQuery=function(a,c,d){var m="",e,f,l,g;for(f in a)if(p.call(a,f)&&f)if(y(a[f]))for(e={},l=0,g=a[f].length;l<g;l++)void 0!==a[f][l]&&void 0===e[a[f][l]+""]&&(m+="&"+b.buildQueryParameter(f,a[f][l],d),!0!==c&&(e[a[f][l]+""]=!0));else void 0!==a[f]&&(m+="&"+b.buildQueryParameter(f,a[f],d));return m.substring(1)};
b.buildQueryParameter=function(a,c,d){return b.encodeQuery(a,d)+(null!==c?"="+b.encodeQuery(c,d):"")};b.addQuery=function(a,c,d){if("object"===typeof c)for(var m in c)p.call(c,m)&&b.addQuery(a,m,c[m]);else if("string"===typeof c)void 0===a[c]?a[c]=d:("string"===typeof a[c]&&(a[c]=[a[c]]),y(d)||(d=[d]),a[c]=(a[c]||[]).concat(d));else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");};b.removeQuery=function(a,c,d){var m;if(y(c))for(d=0,m=c.length;d<m;d++)a[c[d]]=
void 0;else if("RegExp"===A(c))for(m in a)c.test(m)&&(a[m]=void 0);else if("object"===typeof c)for(m in c)p.call(c,m)&&b.removeQuery(a,m,c[m]);else if("string"===typeof c)void 0!==d?"RegExp"===A(d)?!y(a[c])&&d.test(a[c])?a[c]=void 0:a[c]=l(a[c],d):a[c]!==String(d)||y(d)&&1!==d.length?y(a[c])&&(a[c]=l(a[c],d)):a[c]=void 0:a[c]=void 0;else throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");};b.hasQuery=function(a,c,d,m){switch(A(c)){case "String":break;
case "RegExp":for(var e in a)if(p.call(a,e)&&c.test(e)&&(void 0===d||b.hasQuery(a,e,d)))return!0;return!1;case "Object":for(var f in c)if(p.call(c,f)&&!b.hasQuery(a,f,c[f]))return!1;return!0;default:throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter");}switch(A(d)){case "Undefined":return c in a;case "Boolean":return a=!(y(a[c])?!a[c].length:!a[c]),d===a;case "Function":return!!d(a[c],c,a);case "Array":return y(a[c])?(m?q:B)(a[c],d):!1;case "RegExp":return y(a[c])?
m?q(a[c],d):!1:!(!a[c]||!a[c].match(d));case "Number":d=String(d);case "String":return y(a[c])?m?q(a[c],d):!1:a[c]===d;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");}};b.joinPaths=function(){for(var a=[],c=[],d=0,m=0;m<arguments.length;m++){var e=new b(arguments[m]);a.push(e);for(var e=e.segment(),f=0;f<e.length;f++)"string"===typeof e[f]&&c.push(e[f]),e[f]&&d++}if(!c.length||!d)return new b("");c=(new b("")).segment(c);
""!==a[0].path()&&"/"!==a[0].path().slice(0,1)||c.path("/"+c.path());return c.normalize()};b.commonPath=function(a,c){var d=Math.min(a.length,c.length),b;for(b=0;b<d;b++)if(a.charAt(b)!==c.charAt(b)){b--;break}if(1>b)return a.charAt(0)===c.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(b)||"/"!==c.charAt(b))b=a.substring(0,b).lastIndexOf("/");return a.substring(0,b+1)};b.withinString=function(a,c,d){d||(d={});var e=d.start||b.findUri.start,f=d.end||b.findUri.end,l=d.trim||b.findUri.trim,g=
/[a-z0-9-]=["']?$/i;for(e.lastIndex=0;;){var q=e.exec(a);if(!q)break;q=q.index;if(d.ignoreHtml){var k=a.slice(Math.max(q-3,0),q);if(k&&g.test(k))continue}var k=q+a.slice(q).search(f),h=a.slice(q,k).replace(l,"");d.ignore&&d.ignore.test(h)||(k=q+h.length,h=c(h,q,k,a),void 0===h?e.lastIndex=k:(h=String(h),a=a.slice(0,q)+h+a.slice(k),e.lastIndex=q+h.length))}e.lastIndex=0;return a};b.ensureValidHostname=function(a){if(a.match(b.invalid_hostname_characters)){if(!f)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');
if(f.toASCII(a).match(b.invalid_hostname_characters))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');}};b.noConflict=function(a){if(a)return a={URI:this.noConflict()},n.URITemplate&&"function"===typeof n.URITemplate.noConflict&&(a.URITemplate=n.URITemplate.noConflict()),n.IPv6&&"function"===typeof n.IPv6.noConflict&&(a.IPv6=n.IPv6.noConflict()),n.SecondLevelDomains&&"function"===typeof n.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=n.SecondLevelDomains.noConflict()),
a;n.URI===this&&(n.URI=x);return this};e.build=function(a){if(!0===a)this._deferred_build=!0;else if(void 0===a||this._deferred_build)this._string=b.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new b(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};e.protocol=v("protocol");e.username=v("username");e.password=v("password");e.hostname=v("hostname");e.port=v("port");e.query=t("query","?");e.fragment=t("fragment","#");e.search=function(a,c){var d=
this.query(a,c);return"string"===typeof d&&d.length?"?"+d:d};e.hash=function(a,c){var d=this.fragment(a,c);return"string"===typeof d&&d.length?"#"+d:d};e.pathname=function(a,c){if(void 0===a||!0===a){var d=this._parts.path||(this._parts.hostname?"/":"");return a?(this._parts.urn?b.decodeUrnPath:b.decodePath)(d):d}this._parts.path=this._parts.urn?a?b.recodeUrnPath(a):"":a?b.recodePath(a):"/";this.build(!c);return this};e.path=e.pathname;e.href=function(a,c){var d;if(void 0===a)return this.toString();
this._string="";this._parts=b._parts();var e=a instanceof b,f="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(f=b.getDomAttribute(a),a=a[f]||"",f=!1);!e&&f&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a||a instanceof String)this._parts=b.parse(String(a),this._parts);else if(e||f)for(d in e=e?a._parts:a,e)p.call(this._parts,d)&&(this._parts[d]=e[d]);else throw new TypeError("invalid input");this.build(!c);return this};e.is=function(a){var c=!1,d=!1,e=!1,f=!1,l=!1,
q=!1,k=!1,h=!this._parts.urn;this._parts.hostname&&(h=!1,d=b.ip4_expression.test(this._parts.hostname),e=b.ip6_expression.test(this._parts.hostname),c=d||e,l=(f=!c)&&g&&g.has(this._parts.hostname),q=f&&b.idn_expression.test(this._parts.hostname),k=f&&b.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return h;case "absolute":return!h;case "domain":case "name":return f;case "sld":return l;case "ip":return c;case "ip4":case "ipv4":case "inet4":return d;case "ip6":case "ipv6":case "inet6":return e;
case "idn":return q;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return k}return null};var G=e.protocol,H=e.port,I=e.hostname;e.protocol=function(a,c){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(b.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return G.call(this,a,c)};e.scheme=e.protocol;e.port=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0!==
a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError('Port "'+a+'" contains characters other than [0-9]');return H.call(this,a,c)};e.hostname=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var d={};if("/"!==b.parseHost(a,d))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');a=d.hostname}return I.call(this,a,c)};e.origin=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===
a){var d=this.protocol();return this.authority()?(d?d+"://":"")+this.authority():""}d=b(a);this.protocol(d.protocol()).authority(d.authority()).build(!c);return this};e.host=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?b.buildHost(this._parts):"";if("/"!==b.parseHost(a,this._parts))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');this.build(!c);return this};e.authority=function(a,c){if(this._parts.urn)return void 0===
a?"":this;if(void 0===a)return this._parts.hostname?b.buildAuthority(this._parts):"";if("/"!==b.parseAuthority(a,this._parts))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');this.build(!c);return this};e.userinfo=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){var d=b.buildUserinfo(this._parts);return d?d.substring(0,d.length-1):d}"@"!==a[a.length-1]&&(a+="@");b.parseUserinfo(a,this._parts);this.build(!c);return this};e.resource=function(a,
c){var d;if(void 0===a)return this.path()+this.search()+this.hash();d=b.parse(a);this._parts.path=d.path;this._parts.query=d.query;this._parts.fragment=d.fragment;this.build(!c);return this};e.subdomain=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,d)||""}d=this._parts.hostname.length-this.domain().length;d=this._parts.hostname.substring(0,
d);d=new RegExp("^"+k(d));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&b.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(d,a);this.build(!c);return this};e.domain=function(a,c){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(c=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.match(/\./g);if(d&&2>d.length)return this._parts.hostname;d=this._parts.hostname.length-this.tld(c).length-1;d=this._parts.hostname.lastIndexOf(".",
d-1)+1;return this._parts.hostname.substring(d)||""}if(!a)throw new TypeError("cannot set domain empty");b.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(d=new RegExp(k(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a));this.build(!c);return this};e.tld=function(a,c){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(c=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.lastIndexOf("."),
d=this._parts.hostname.substring(d+1);return!0!==c&&g&&g.list[d.toLowerCase()]?g.get(this._parts.hostname)||d:d}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(g&&g.is(a))d=new RegExp(k(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");d=new RegExp(k(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(d,
a)}else throw new TypeError("cannot set TLD empty");this.build(!c);return this};e.directory=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var d=this._parts.path.length-this.filename().length-1,d=this._parts.path.substring(0,d)||(this._parts.hostname?"/":"");return a?b.decodePath(d):d}d=this._parts.path.length-this.filename().length;d=this._parts.path.substring(0,d);d=new RegExp("^"+
k(d));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=b.recodePath(a);this._parts.path=this._parts.path.replace(d,a);this.build(!c);return this};e.filename=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var d=this._parts.path.lastIndexOf("/"),d=this._parts.path.substring(d+1);return a?b.decodePathSegment(d):d}d=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&
(d=!0);var e=new RegExp(k(this.filename())+"$");a=b.recodePath(a);this._parts.path=this._parts.path.replace(e,a);d?this.normalizePath(c):this.build(!c);return this};e.suffix=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var d=this.filename(),e=d.lastIndexOf(".");if(-1===e)return"";d=d.substring(e+1);d=/^[a-z0-9%]+$/i.test(d)?d:"";return a?b.decodePathSegment(d):d}"."===a.charAt(0)&&(a=a.substring(1));if(d=this.suffix())e=
a?new RegExp(k(d)+"$"):new RegExp(k("."+d)+"$");else{if(!a)return this;this._parts.path+="."+b.recodePath(a)}e&&(a=b.recodePath(a),this._parts.path=this._parts.path.replace(e,a));this.build(!c);return this};e.segment=function(a,c,d){var b=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),e=e.split(b);void 0!==a&&"number"!==typeof a&&(d=c,c=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');f&&e.shift();0>a&&(a=Math.max(e.length+
a,0));if(void 0===c)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(y(c)){e=[];a=0;for(var l=c.length;a<l;a++)if(c[a].length||e.length&&e[e.length-1].length)e.length&&!e[e.length-1].length&&e.pop(),e.push(E(c[a]))}else{if(c||"string"===typeof c)c=E(c),""===e[e.length-1]?e[e.length-1]=c:e.push(c)}else c?e[a]=E(c):e.splice(a,1);f&&e.unshift("");return this.path(e.join(b),d)};e.segmentCoded=function(a,c,d){var e,f;"number"!==typeof a&&(d=c,c=a,a=void 0);if(void 0===c){a=this.segment(a,c,d);if(y(a))for(e=
0,f=a.length;e<f;e++)a[e]=b.decode(a[e]);else a=void 0!==a?b.decode(a):void 0;return a}if(y(c))for(e=0,f=c.length;e<f;e++)c[e]=b.encode(c[e]);else c="string"===typeof c||c instanceof String?b.encode(c):c;return this.segment(a,c,d)};var J=e.query;e.query=function(a,c){if(!0===a)return b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"===typeof a){var d=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace),e=a.call(this,d);this._parts.query=b.buildQuery(e||d,this._parts.duplicateQueryParameters,
this._parts.escapeQuerySpace);this.build(!c);return this}return void 0!==a&&"string"!==typeof a?(this._parts.query=b.buildQuery(a,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!c),this):J.call(this,a,c)};e.setQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("string"===typeof a||a instanceof String)e[a]=void 0!==c?c:null;else if("object"===typeof a)for(var f in a)p.call(a,f)&&(e[f]=a[f]);else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
this._parts.query=b.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=c);this.build(!d);return this};e.addQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);b.addQuery(e,a,void 0===c?null:c);this._parts.query=b.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=c);this.build(!d);return this};e.removeQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,
this._parts.escapeQuerySpace);b.removeQuery(e,a,c);this._parts.query=b.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=c);this.build(!d);return this};e.hasQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return b.hasQuery(e,a,c,d)};e.setSearch=e.setQuery;e.addSearch=e.addQuery;e.removeSearch=e.removeQuery;e.hasSearch=e.hasQuery;e.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():
this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()};e.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!a));return this};e.normalizeHostname=function(a){this._parts.hostname&&(this.is("IDN")&&f?this._parts.hostname=f.toASCII(this._parts.hostname):this.is("IPv6")&&h&&(this._parts.hostname=h.best(this._parts.hostname)),this._parts.hostname=
this._parts.hostname.toLowerCase(),this.build(!a));return this};e.normalizePort=function(a){"string"===typeof this._parts.protocol&&this._parts.port===b.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};e.normalizePath=function(a){var c=this._parts.path;if(!c)return this;if(this._parts.urn)return this._parts.path=b.recodeUrnPath(this._parts.path),this.build(!a),this;if("/"===this._parts.path)return this;var c=b.recodePath(c),d,e="",f,l;"/"!==c.charAt(0)&&(d=!0,
c="/"+c);if("/.."===c.slice(-3)||"/."===c.slice(-2))c+="/";c=c.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/");d&&(e=c.substring(1).match(/^(\.\.\/)+/)||"")&&(e=e[0]);for(;;){f=c.search(/\/\.\.(\/|$)/);if(-1===f)break;else if(0===f){c=c.substring(3);continue}l=c.substring(0,f).lastIndexOf("/");-1===l&&(l=f);c=c.substring(0,l)+c.substring(f+3)}d&&this.is("relative")&&(c=e+c.substring(1));this._parts.path=c;this.build(!a);return this};e.normalizePathname=e.normalizePath;e.normalizeQuery=
function(a){"string"===typeof this._parts.query&&(this._parts.query.length?this.query(b.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!a));return this};e.normalizeFragment=function(a){this._parts.fragment||(this._parts.fragment=null,this.build(!a));return this};e.normalizeSearch=e.normalizeQuery;e.normalizeHash=e.normalizeFragment;e.iso8859=function(){var a=b.encode,c=b.decode;b.encode=escape;b.decode=decodeURIComponent;try{this.normalize()}finally{b.encode=
a,b.decode=c}return this};e.unicode=function(){var a=b.encode,c=b.decode;b.encode=r;b.decode=unescape;try{this.normalize()}finally{b.encode=a,b.decode=c}return this};e.readable=function(){var a=this.clone();a.username("").password("").normalize();var c="";a._parts.protocol&&(c+=a._parts.protocol+"://");a._parts.hostname&&(a.is("punycode")&&f?(c+=f.toUnicode(a._parts.hostname),a._parts.port&&(c+=":"+a._parts.port)):c+=a.host());a._parts.hostname&&a._parts.path&&"/"!==a._parts.path.charAt(0)&&(c+="/");
c+=a.path(!0);if(a._parts.query){for(var d="",e=0,l=a._parts.query.split("&"),g=l.length;e<g;e++){var q=(l[e]||"").split("="),d=d+("&"+b.decodeQuery(q[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"));void 0!==q[1]&&(d+="="+b.decodeQuery(q[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}c+="?"+d.substring(1)}return c+=b.decodeQuery(a.hash(),!0)};e.absoluteTo=function(a){var c=this.clone(),d=["protocol","username","password","hostname","port"],e,f;if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");
a instanceof b||(a=new b(a));c._parts.protocol||(c._parts.protocol=a._parts.protocol);if(this._parts.hostname)return c;for(e=0;f=d[e];e++)c._parts[f]=a._parts[f];c._parts.path?(".."===c._parts.path.substring(-2)&&(c._parts.path+="/"),"/"!==c.path().charAt(0)&&(d=(d=a.directory())?d:0===a.path().indexOf("/")?"/":"",c._parts.path=(d?d+"/":"")+c._parts.path,c.normalizePath())):(c._parts.path=a._parts.path,c._parts.query||(c._parts.query=a._parts.query));c.build();return c};e.relativeTo=function(a){var c=
this.clone().normalize(),d,e,f;if(c._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a=(new b(a)).normalize();d=c._parts;e=a._parts;f=c.path();a=a.path();if("/"!==f.charAt(0))throw Error("URI is already relative");if("/"!==a.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");d.protocol===e.protocol&&(d.protocol=null);if(d.username===e.username&&d.password===e.password&&null===d.protocol&&null===d.username&&null===d.password&&d.hostname===
e.hostname&&d.port===e.port)d.hostname=null,d.port=null;else return c.build();if(f===a)return d.path="",c.build();f=b.commonPath(f,a);if(!f)return c.build();e=e.path.substring(f.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");d.path=e+d.path.substring(f.length)||"./";return c.build()};e.equals=function(a){var c=this.clone(),d=new b(a),e;a={};var f,l;c.normalize();d.normalize();if(c.toString()===d.toString())return!0;f=c.query();e=d.query();c.query("");d.query("");if(c.toString()!==d.toString()||
f.length!==e.length)return!1;c=b.parseQuery(f,this._parts.escapeQuerySpace);e=b.parseQuery(e,this._parts.escapeQuerySpace);for(l in c)if(p.call(c,l)){if(!y(c[l])){if(c[l]!==e[l])return!1}else if(!B(c[l],e[l]))return!1;a[l]=!0}for(l in e)if(p.call(e,l)&&!a[l])return!1;return!0};e.duplicateQueryParameters=function(a){this._parts.duplicateQueryParameters=!!a;return this};e.escapeQuerySpace=function(a){this._parts.escapeQuerySpace=!!a;return this};return b});
(function(f,h){"object"===typeof exports?module.exports=h(require("./URI")):"function"===typeof define&&define.amd?define(["./URI"],h):f.URITemplate=h(f.URI,f)})(this,function(f,h){function g(b){if(g._cache[b])return g._cache[b];if(!(this instanceof g))return new g(b);this.expression=b;g._cache[b]=this;return this}function n(b){this.data=b;this.cache={}}var b=h&&h.URITemplate,k=Object.prototype.hasOwnProperty,A=g.prototype,y={"":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encode"},
"+":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},"#":{prefix:"#",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},".":{prefix:".",separator:".",named:!1,empty_name_separator:!1,encode:"encode"},"/":{prefix:"/",separator:"/",named:!1,empty_name_separator:!1,encode:"encode"},";":{prefix:";",separator:";",named:!0,empty_name_separator:!1,encode:"encode"},"?":{prefix:"?",separator:"&",named:!0,empty_name_separator:!0,encode:"encode"},"&":{prefix:"&",
separator:"&",named:!0,empty_name_separator:!0,encode:"encode"}};g._cache={};g.EXPRESSION_PATTERN=/\{([^a-zA-Z0-9%_]?)([^\}]+)(\}|$)/g;g.VARIABLE_PATTERN=/^([^*:.](?:\.?[^*:.])*)((\*)|:(\d+))?$/;g.VARIABLE_NAME_PATTERN=/[^a-zA-Z0-9%_.]/;g.LITERAL_PATTERN=/[<>{}'"`^| \\]/;g.expand=function(b,f){var k=y[b.operator],h=k.named?"Named":"Unnamed",n=b.variables,r=[],v,t,x;for(x=0;t=n[x];x++)if(v=f.get(t.name),v.val.length){if(1<v.type&&t.maxlength)throw Error('Invalid expression: Prefix modifier not applicable to variable "'+
t.name+'"');r.push(g["expand"+h](v,k,t.explode,t.explode&&k.separator||",",t.maxlength,t.name))}else v.type&&r.push("");return r.length?k.prefix+r.join(k.separator):""};g.expandNamed=function(b,g,k,h,n,r){var v="",t=g.encode;g=g.empty_name_separator;var x=!b[t].length,e=2===b.type?"":f[t](r),p,u,y;u=0;for(y=b.val.length;u<y;u++)n?(p=f[t](b.val[u][1].substring(0,n)),2===b.type&&(e=f[t](b.val[u][0].substring(0,n)))):x?(p=f[t](b.val[u][1]),2===b.type?(e=f[t](b.val[u][0]),b[t].push([e,p])):b[t].push([void 0,
p])):(p=b[t][u][1],2===b.type&&(e=b[t][u][0])),v&&(v+=h),k?v+=e+(g||p?"=":"")+p:(u||(v+=f[t](r)+(g||p?"=":"")),2===b.type&&(v+=e+","),v+=p);return v};g.expandUnnamed=function(b,g,k,h,n){var r="",v=g.encode;g=g.empty_name_separator;var t=!b[v].length,x,e,p,u;p=0;for(u=b.val.length;p<u;p++)n?e=f[v](b.val[p][1].substring(0,n)):t?(e=f[v](b.val[p][1]),b[v].push([2===b.type?f[v](b.val[p][0]):void 0,e])):e=b[v][p][1],r&&(r+=h),2===b.type&&(x=n?f[v](b.val[p][0].substring(0,n)):b[v][p][0],r+=x,r=k?r+(g||e?
"=":""):r+","),r+=e;return r};g.noConflict=function(){h.URITemplate===g&&(h.URITemplate=b);return g};A.expand=function(b){var f="";this.parts&&this.parts.length||this.parse();b instanceof n||(b=new n(b));for(var k=0,h=this.parts.length;k<h;k++)f+="string"===typeof this.parts[k]?this.parts[k]:g.expand(this.parts[k],b);return f};A.parse=function(){var b=this.expression,f=g.EXPRESSION_PATTERN,k=g.VARIABLE_PATTERN,h=g.VARIABLE_NAME_PATTERN,n=g.LITERAL_PATTERN,r=[],v=0,t,x,e,p=function(b){if(b.match(n))throw Error('Invalid Literal "'+
b+'"');return b};for(f.lastIndex=0;;){x=f.exec(b);if(null===x){r.push(p(b.substring(v)));break}else r.push(p(b.substring(v,x.index))),v=x.index+x[0].length;if(!y[x[1]])throw Error('Unknown Operator "'+x[1]+'" in "'+x[0]+'"');if(!x[3])throw Error('Unclosed Expression "'+x[0]+'"');t=x[2].split(",");for(var u=0,A=t.length;u<A;u++){e=t[u].match(k);if(null===e)throw Error('Invalid Variable "'+t[u]+'" in "'+x[0]+'"');if(e[1].match(h))throw Error('Invalid Variable Name "'+e[1]+'" in "'+x[0]+'"');t[u]={name:e[1],
explode:!!e[3],maxlength:e[4]&&parseInt(e[4],10)}}if(!t.length)throw Error('Expression Missing Variable(s) "'+x[0]+'"');r.push({expression:x[0],operator:x[1],variables:t})}r.length||r.push(p(b));this.parts=r;return this};n.prototype.get=function(b){var f=this.data,g={type:0,val:[],encode:[],encodeReserved:[]},h;if(void 0!==this.cache[b])return this.cache[b];this.cache[b]=g;f="[object Function]"===String(Object.prototype.toString.call(f))?f(b):"[object Function]"===String(Object.prototype.toString.call(f[b]))?
f[b](b):f[b];if(void 0!==f&&null!==f)if("[object Array]"===String(Object.prototype.toString.call(f))){h=0;for(b=f.length;h<b;h++)void 0!==f[h]&&null!==f[h]&&g.val.push([void 0,String(f[h])]);g.val.length&&(g.type=3)}else if("[object Object]"===String(Object.prototype.toString.call(f))){for(h in f)k.call(f,h)&&void 0!==f[h]&&null!==f[h]&&g.val.push([h,String(f[h])]);g.val.length&&(g.type=2)}else g.type=1,g.val.push([void 0,String(f)]);return g};f.expand=function(b,h){var k=(new g(b)).expand(h);return new f(k)};
return g});

513
src/URITemplate.js Normal file
View File

@ -0,0 +1,513 @@
/*!
* URI.js - Mutating URLs
* URI Template Support - http://tools.ietf.org/html/rfc6570
*
* Version: 1.18.2
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
*/
(function (root, factory) {
'use strict';
// https://github.com/umdjs/umd/blob/master/returnExports.js
if (typeof exports === 'object') {
// Node
module.exports = factory(require('./URI'));
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['./URI'], factory);
} else {
// Browser globals (root is window)
root.URITemplate = factory(root.URI, root);
}
}(this, function (URI, root) {
'use strict';
// FIXME: v2.0.0 renamce non-camelCase properties to uppercase
/*jshint camelcase: false */
// save current URITemplate variable, if any
var _URITemplate = root && root.URITemplate;
var hasOwn = Object.prototype.hasOwnProperty;
function URITemplate(expression) {
// serve from cache where possible
if (URITemplate._cache[expression]) {
return URITemplate._cache[expression];
}
// Allow instantiation without the 'new' keyword
if (!(this instanceof URITemplate)) {
return new URITemplate(expression);
}
this.expression = expression;
URITemplate._cache[expression] = this;
return this;
}
function Data(data) {
this.data = data;
this.cache = {};
}
var p = URITemplate.prototype;
// list of operators and their defined options
var operators = {
// Simple string expansion
'' : {
prefix: '',
separator: ',',
named: false,
empty_name_separator: false,
encode : 'encode'
},
// Reserved character strings
'+' : {
prefix: '',
separator: ',',
named: false,
empty_name_separator: false,
encode : 'encodeReserved'
},
// Fragment identifiers prefixed by '#'
'#' : {
prefix: '#',
separator: ',',
named: false,
empty_name_separator: false,
encode : 'encodeReserved'
},
// Name labels or extensions prefixed by '.'
'.' : {
prefix: '.',
separator: '.',
named: false,
empty_name_separator: false,
encode : 'encode'
},
// Path segments prefixed by '/'
'/' : {
prefix: '/',
separator: '/',
named: false,
empty_name_separator: false,
encode : 'encode'
},
// Path parameter name or name=value pairs prefixed by ';'
';' : {
prefix: ';',
separator: ';',
named: true,
empty_name_separator: false,
encode : 'encode'
},
// Query component beginning with '?' and consisting
// of name=value pairs separated by '&'; an
'?' : {
prefix: '?',
separator: '&',
named: true,
empty_name_separator: true,
encode : 'encode'
},
// Continuation of query-style &name=value pairs
// within a literal query component.
'&' : {
prefix: '&',
separator: '&',
named: true,
empty_name_separator: true,
encode : 'encode'
}
// The operator characters equals ("="), comma (","), exclamation ("!"),
// at sign ("@"), and pipe ("|") are reserved for future extensions.
};
// storage for already parsed templates
URITemplate._cache = {};
// pattern to identify expressions [operator, variable-list] in template
URITemplate.EXPRESSION_PATTERN = /\{([^a-zA-Z0-9%_]?)([^\}]+)(\}|$)/g;
// pattern to identify variables [name, explode, maxlength] in variable-list
URITemplate.VARIABLE_PATTERN = /^([^*:.](?:\.?[^*:.])*)((\*)|:(\d+))?$/;
// pattern to verify variable name integrity
URITemplate.VARIABLE_NAME_PATTERN = /[^a-zA-Z0-9%_.]/;
// pattern to verify literal integrity
URITemplate.LITERAL_PATTERN = /[<>{}'"`^| \\]/;
// expand parsed expression (expression, not template!)
URITemplate.expand = function(expression, data) {
// container for defined options for the given operator
var options = operators[expression.operator];
// expansion type (include keys or not)
var type = options.named ? 'Named' : 'Unnamed';
// list of variables within the expression
var variables = expression.variables;
// result buffer for evaluating the expression
var buffer = [];
var d, variable, i;
for (i = 0; (variable = variables[i]); i++) {
// fetch simplified data source
d = data.get(variable.name);
if (!d.val.length) {
if (d.type) {
// empty variables (empty string)
// still lead to a separator being appended!
buffer.push('');
}
// no data, no action
continue;
}
if (d.type > 1 && variable.maxlength) {
// composite variable cannot specify maxlength
throw new Error('Invalid expression: Prefix modifier not applicable to variable "' + variable.name + '"');
}
// expand the given variable
buffer.push(URITemplate['expand' + type](
d,
options,
variable.explode,
variable.explode && options.separator || ',',
variable.maxlength,
variable.name
));
}
if (buffer.length) {
return options.prefix + buffer.join(options.separator);
} else {
// prefix is not prepended for empty expressions
return '';
}
};
// expand a named variable
URITemplate.expandNamed = function(d, options, explode, separator, length, name) {
// variable result buffer
var result = '';
// peformance crap
var encode = options.encode;
var empty_name_separator = options.empty_name_separator;
// flag noting if values are already encoded
var _encode = !d[encode].length;
// key for named expansion
var _name = d.type === 2 ? '': URI[encode](name);
var _value, i, l;
// for each found value
for (i = 0, l = d.val.length; i < l; i++) {
if (length) {
// maxlength must be determined before encoding can happen
_value = URI[encode](d.val[i][1].substring(0, length));
if (d.type === 2) {
// apply maxlength to keys of objects as well
_name = URI[encode](d.val[i][0].substring(0, length));
}
} else if (_encode) {
// encode value
_value = URI[encode](d.val[i][1]);
if (d.type === 2) {
// encode name and cache encoded value
_name = URI[encode](d.val[i][0]);
d[encode].push([_name, _value]);
} else {
// cache encoded value
d[encode].push([undefined, _value]);
}
} else {
// values are already encoded and can be pulled from cache
_value = d[encode][i][1];
if (d.type === 2) {
_name = d[encode][i][0];
}
}
if (result) {
// unless we're the first value, prepend the separator
result += separator;
}
if (!explode) {
if (!i) {
// first element, so prepend variable name
result += URI[encode](name) + (empty_name_separator || _value ? '=' : '');
}
if (d.type === 2) {
// without explode-modifier, keys of objects are returned comma-separated
result += _name + ',';
}
result += _value;
} else {
// only add the = if it is either default (?&) or there actually is a value (;)
result += _name + (empty_name_separator || _value ? '=' : '') + _value;
}
}
return result;
};
// expand an unnamed variable
URITemplate.expandUnnamed = function(d, options, explode, separator, length) {
// variable result buffer
var result = '';
// performance crap
var encode = options.encode;
var empty_name_separator = options.empty_name_separator;
// flag noting if values are already encoded
var _encode = !d[encode].length;
var _name, _value, i, l;
// for each found value
for (i = 0, l = d.val.length; i < l; i++) {
if (length) {
// maxlength must be determined before encoding can happen
_value = URI[encode](d.val[i][1].substring(0, length));
} else if (_encode) {
// encode and cache value
_value = URI[encode](d.val[i][1]);
d[encode].push([
d.type === 2 ? URI[encode](d.val[i][0]) : undefined,
_value
]);
} else {
// value already encoded, pull from cache
_value = d[encode][i][1];
}
if (result) {
// unless we're the first value, prepend the separator
result += separator;
}
if (d.type === 2) {
if (length) {
// maxlength also applies to keys of objects
_name = URI[encode](d.val[i][0].substring(0, length));
} else {
// at this point the name must already be encoded
_name = d[encode][i][0];
}
result += _name;
if (explode) {
// explode-modifier separates name and value by "="
result += (empty_name_separator || _value ? '=' : '');
} else {
// no explode-modifier separates name and value by ","
result += ',';
}
}
result += _value;
}
return result;
};
URITemplate.noConflict = function() {
if (root.URITemplate === URITemplate) {
root.URITemplate = _URITemplate;
}
return URITemplate;
};
// expand template through given data map
p.expand = function(data) {
var result = '';
if (!this.parts || !this.parts.length) {
// lazilyy parse the template
this.parse();
}
if (!(data instanceof Data)) {
// make given data available through the
// optimized data handling thingie
data = new Data(data);
}
for (var i = 0, l = this.parts.length; i < l; i++) {
/*jshint laxbreak: true */
result += typeof this.parts[i] === 'string'
// literal string
? this.parts[i]
// expression
: URITemplate.expand(this.parts[i], data);
/*jshint laxbreak: false */
}
return result;
};
// parse template into action tokens
p.parse = function() {
// performance crap
var expression = this.expression;
var ePattern = URITemplate.EXPRESSION_PATTERN;
var vPattern = URITemplate.VARIABLE_PATTERN;
var nPattern = URITemplate.VARIABLE_NAME_PATTERN;
var lPattern = URITemplate.LITERAL_PATTERN;
// token result buffer
var parts = [];
// position within source template
var pos = 0;
var variables, eMatch, vMatch;
var checkLiteral = function(literal) {
if (literal.match(lPattern)) {
throw new Error('Invalid Literal "' + literal + '"');
}
return literal;
};
// RegExp is shared accross all templates,
// which requires a manual reset
ePattern.lastIndex = 0;
// I don't like while(foo = bar()) loops,
// to make things simpler I go while(true) and break when required
while (true) {
eMatch = ePattern.exec(expression);
if (eMatch === null) {
// push trailing literal
parts.push(checkLiteral(expression.substring(pos)));
break;
} else {
// push leading literal
parts.push(checkLiteral(expression.substring(pos, eMatch.index)));
pos = eMatch.index + eMatch[0].length;
}
if (!operators[eMatch[1]]) {
throw new Error('Unknown Operator "' + eMatch[1] + '" in "' + eMatch[0] + '"');
} else if (!eMatch[3]) {
throw new Error('Unclosed Expression "' + eMatch[0] + '"');
}
// parse variable-list
variables = eMatch[2].split(',');
for (var i = 0, l = variables.length; i < l; i++) {
vMatch = variables[i].match(vPattern);
if (vMatch === null) {
throw new Error('Invalid Variable "' + variables[i] + '" in "' + eMatch[0] + '"');
} else if (vMatch[1].match(nPattern)) {
throw new Error('Invalid Variable Name "' + vMatch[1] + '" in "' + eMatch[0] + '"');
}
variables[i] = {
name: vMatch[1],
explode: !!vMatch[3],
maxlength: vMatch[4] && parseInt(vMatch[4], 10)
};
}
if (!variables.length) {
throw new Error('Expression Missing Variable(s) "' + eMatch[0] + '"');
}
parts.push({
expression: eMatch[0],
operator: eMatch[1],
variables: variables
});
}
if (!parts.length) {
// template doesn't contain any expressions
// so it is a simple literal string
// this probably should fire a warning or something?
parts.push(checkLiteral(expression));
}
this.parts = parts;
return this;
};
// simplify data structures
Data.prototype.get = function(key) {
// performance crap
var data = this.data;
// cache for processed data-point
var d = {
// type of data 0: undefined/null, 1: string, 2: object, 3: array
type: 0,
// original values (except undefined/null)
val: [],
// cache for encoded values (only for non-maxlength expansion)
encode: [],
encodeReserved: []
};
var i, l, value;
if (this.cache[key] !== undefined) {
// we've already processed this key
return this.cache[key];
}
this.cache[key] = d;
if (String(Object.prototype.toString.call(data)) === '[object Function]') {
// data itself is a callback (global callback)
value = data(key);
} else if (String(Object.prototype.toString.call(data[key])) === '[object Function]') {
// data is a map of callbacks (local callback)
value = data[key](key);
} else {
// data is a map of data
value = data[key];
}
// generalize input into [ [name1, value1], [name2, value2], … ]
// so expansion has to deal with a single data structure only
if (value === undefined || value === null) {
// undefined and null values are to be ignored completely
return d;
} else if (String(Object.prototype.toString.call(value)) === '[object Array]') {
for (i = 0, l = value.length; i < l; i++) {
if (value[i] !== undefined && value[i] !== null) {
// arrays don't have names
d.val.push([undefined, String(value[i])]);
}
}
if (d.val.length) {
// only treat non-empty arrays as arrays
d.type = 3; // array
}
} else if (String(Object.prototype.toString.call(value)) === '[object Object]') {
for (i in value) {
if (hasOwn.call(value, i) && value[i] !== undefined && value[i] !== null) {
// objects have keys, remember them for named expansion
d.val.push([i, String(value[i])]);
}
}
if (d.val.length) {
// only treat non-empty objects as objects
d.type = 2; // object
}
} else {
d.type = 1; // primitive string (could've been string, number, boolean and objects with a toString())
// arrays don't have names
d.val.push([undefined, String(value)]);
}
return d;
};
// hook into URI for fluid access
URI.expand = function(expression, data) {
var template = new URITemplate(expression);
var expansion = template.expand(data);
return new URI(expansion);
};
return URITemplate;
}));

234
src/jquery.URI.js Normal file
View File

@ -0,0 +1,234 @@
/*!
* URI.js - Mutating URLs
* jQuery Plugin
*
* Version: 1.18.2
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/jquery-uri-plugin.html
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
*/
(function (root, factory) {
'use strict';
// https://github.com/umdjs/umd/blob/master/returnExports.js
if (typeof exports === 'object') {
// Node
module.exports = factory(require('jquery'), require('./URI'));
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', './URI'], factory);
} else {
// Browser globals (root is window)
factory(root.jQuery, root.URI);
}
}(this, function ($, URI) {
'use strict';
// FIXME: v2.0.0 renamce non-camelCase properties to uppercase
/*jshint camelcase: false */
var comparable = {};
var compare = {
// equals
'=': function(value, target) {
return value === target;
},
// ~= translates to value.match((?:^|\s)target(?:\s|$)) which is useless for URIs
// |= translates to value.match((?:\b)target(?:-|\s|$)) which is useless for URIs
// begins with
'^=': function(value, target) {
return !!(value + '').match(new RegExp('^' + escapeRegEx(target), 'i'));
},
// ends with
'$=': function(value, target) {
return !!(value + '').match(new RegExp(escapeRegEx(target) + '$', 'i'));
},
// contains
'*=': function(value, target, property) {
if (property === 'directory') {
// add trailing slash so /dir/ will match the deep-end as well
value += '/';
}
return !!(value + '').match(new RegExp(escapeRegEx(target), 'i'));
},
'equals:': function(uri, target) {
return uri.equals(target);
},
'is:': function(uri, target) {
return uri.is(target);
}
};
function escapeRegEx(string) {
// https://github.com/medialize/URI.js/commit/85ac21783c11f8ccab06106dba9735a31a86924d#commitcomment-821963
return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
}
function getUriProperty(elem) {
var nodeName = elem.nodeName.toLowerCase();
var property = URI.domAttributes[nodeName];
if (nodeName === 'input' && elem.type !== 'image') {
// compensate ambiguous <input> that is not an image
return undefined;
}
// NOTE: as we use a static mapping from element to attribute,
// the HTML5 attribute issue should not come up again
// https://github.com/medialize/URI.js/issues/69
return property;
}
function generateAccessor(property) {
return {
get: function(elem) {
return $(elem).uri()[property]();
},
set: function(elem, value) {
$(elem).uri()[property](value);
return value;
}
};
}
// populate lookup table and register $.attr('uri:accessor') handlers
$.each('origin authority directory domain filename fragment hash host hostname href password path pathname port protocol query resource scheme search subdomain suffix tld username'.split(' '), function(k, v) {
comparable[v] = true;
$.attrHooks['uri:' + v] = generateAccessor(v);
});
// pipe $.attr('src') and $.attr('href') through URI.js
var _attrHooks = {
get: function(elem) {
return $(elem).uri();
},
set: function(elem, value) {
return $(elem).uri().href(value).toString();
}
};
$.each(['src', 'href', 'action', 'uri', 'cite'], function(k, v) {
$.attrHooks[v] = {
set: _attrHooks.set
};
});
$.attrHooks.uri.get = _attrHooks.get;
// general URI accessor
$.fn.uri = function(uri) {
var $this = this.first();
var elem = $this.get(0);
var property = getUriProperty(elem);
if (!property) {
throw new Error('Element "' + elem.nodeName + '" does not have either property: href, src, action, cite');
}
if (uri !== undefined) {
var old = $this.data('uri');
if (old) {
return old.href(uri);
}
if (!(uri instanceof URI)) {
uri = URI(uri || '');
}
} else {
uri = $this.data('uri');
if (uri) {
return uri;
} else {
uri = URI($this.attr(property) || '');
}
}
uri._dom_element = elem;
uri._dom_attribute = property;
uri.normalize();
$this.data('uri', uri);
return uri;
};
// overwrite URI.build() to update associated DOM element if necessary
URI.prototype.build = function(deferBuild) {
if (this._dom_element) {
// cannot defer building when hooked into a DOM element
this._string = URI.build(this._parts);
this._deferred_build = false;
this._dom_element.setAttribute(this._dom_attribute, this._string);
this._dom_element[this._dom_attribute] = this._string;
} else if (deferBuild === true) {
this._deferred_build = true;
} else if (deferBuild === undefined || this._deferred_build) {
this._string = URI.build(this._parts);
this._deferred_build = false;
}
return this;
};
// add :uri() pseudo class selector to sizzle
var uriSizzle;
var pseudoArgs = /^([a-zA-Z]+)\s*([\^\$*]?=|:)\s*(['"]?)(.+)\3|^\s*([a-zA-Z0-9]+)\s*$/;
function uriPseudo (elem, text) {
var match, property, uri;
// skip anything without src|href|action and bad :uri() syntax
if (!getUriProperty(elem) || !text) {
return false;
}
match = text.match(pseudoArgs);
if (!match || (!match[5] && match[2] !== ':' && !compare[match[2]])) {
// abort because the given selector cannot be executed
// filers seem to fail silently
return false;
}
uri = $(elem).uri();
if (match[5]) {
return uri.is(match[5]);
} else if (match[2] === ':') {
property = match[1].toLowerCase() + ':';
if (!compare[property]) {
// filers seem to fail silently
return false;
}
return compare[property](uri, match[4]);
} else {
property = match[1].toLowerCase();
if (!comparable[property]) {
// filers seem to fail silently
return false;
}
return compare[match[2]](uri[property](), match[4], property);
}
return false;
}
if ($.expr.createPseudo) {
// jQuery >= 1.8
uriSizzle = $.expr.createPseudo(function (text) {
return function (elem) {
return uriPseudo(elem, text);
};
});
} else {
// jQuery < 1.8
uriSizzle = function (elem, i, match) {
return uriPseudo(elem, match[3]);
};
}
$.expr[':'].uri = uriSizzle;
// extending existing object rather than defining something new,
// return jQuery anyway
return $;
}));

7
src/jquery.URI.min.js vendored Normal file
View File

@ -0,0 +1,7 @@
/*! URI.js v1.18.2 http://medialize.github.io/URI.js/ */
/* build contains: jquery.URI.js */
(function(d,e){"object"===typeof exports?module.exports=e(require("jquery"),require("./URI")):"function"===typeof define&&define.amd?define(["jquery","./URI"],e):e(d.jQuery,d.URI)})(this,function(d,e){function h(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function k(a){var b=a.nodeName.toLowerCase();return"input"===b&&"image"!==a.type?void 0:e.domAttributes[b]}function p(a){return{get:function(b){return d(b).uri()[a]()},set:function(b,c){d(b).uri()[a](c);return c}}}function l(a,b){var c,
e,f;if(!k(a)||!b)return!1;c=b.match(q);if(!c||!c[5]&&":"!==c[2]&&!g[c[2]])return!1;f=d(a).uri();if(c[5])return f.is(c[5]);if(":"===c[2])return e=c[1].toLowerCase()+":",g[e]?g[e](f,c[4]):!1;e=c[1].toLowerCase();return m[e]?g[c[2]](f[e](),c[4],e):!1}var m={},g={"=":function(a,b){return a===b},"^=":function(a,b){return!!(a+"").match(new RegExp("^"+h(b),"i"))},"$=":function(a,b){return!!(a+"").match(new RegExp(h(b)+"$","i"))},"*=":function(a,b,c){"directory"===c&&(a+="/");return!!(a+"").match(new RegExp(h(b),
"i"))},"equals:":function(a,b){return a.equals(b)},"is:":function(a,b){return a.is(b)}};d.each("origin authority directory domain filename fragment hash host hostname href password path pathname port protocol query resource scheme search subdomain suffix tld username".split(" "),function(a,b){m[b]=!0;d.attrHooks["uri:"+b]=p(b)});var r=function(a,b){return d(a).uri().href(b).toString()};d.each(["src","href","action","uri","cite"],function(a,b){d.attrHooks[b]={set:r}});d.attrHooks.uri.get=function(a){return d(a).uri()};
d.fn.uri=function(a){var b=this.first(),c=b.get(0),d=k(c);if(!d)throw Error('Element "'+c.nodeName+'" does not have either property: href, src, action, cite');if(void 0!==a){var f=b.data("uri");if(f)return f.href(a);a instanceof e||(a=e(a||""))}else{if(a=b.data("uri"))return a;a=e(b.attr(d)||"")}a._dom_element=c;a._dom_attribute=d;a.normalize();b.data("uri",a);return a};e.prototype.build=function(a){if(this._dom_element)this._string=e.build(this._parts),this._deferred_build=!1,this._dom_element.setAttribute(this._dom_attribute,
this._string),this._dom_element[this._dom_attribute]=this._string;else if(!0===a)this._deferred_build=!0;else if(void 0===a||this._deferred_build)this._string=e.build(this._parts),this._deferred_build=!1;return this};var n,q=/^([a-zA-Z]+)\s*([\^\$*]?=|:)\s*(['"]?)(.+)\3|^\s*([a-zA-Z0-9]+)\s*$/;n=d.expr.createPseudo?d.expr.createPseudo(function(a){return function(b){return l(b,a)}}):function(a,b,c){return l(a,c[3])};d.expr[":"].uri=n;return d});

533
src/punycode.js Normal file
View File

@ -0,0 +1,533 @@
/*! https://mths.be/punycode v1.4.0 by @mathias */
;(function(root) {
/** Detect free variables */
var freeExports = typeof exports == 'object' && exports &&
!exports.nodeType && exports;
var freeModule = typeof module == 'object' && module &&
!module.nodeType && module;
var freeGlobal = typeof global == 'object' && global;
if (
freeGlobal.global === freeGlobal ||
freeGlobal.window === freeGlobal ||
freeGlobal.self === freeGlobal
) {
root = freeGlobal;
}
/**
* The `punycode` object.
* @name punycode
* @type Object
*/
var punycode,
/** Highest positive signed 32-bit float value */
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
/** Bootstring parameters */
base = 36,
tMin = 1,
tMax = 26,
skew = 38,
damp = 700,
initialBias = 72,
initialN = 128, // 0x80
delimiter = '-', // '\x2D'
/** Regular expressions */
regexPunycode = /^xn--/,
regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
/** Error messages */
errors = {
'overflow': 'Overflow: input needs wider integers to process',
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
'invalid-input': 'Invalid input'
},
/** Convenience shortcuts */
baseMinusTMin = base - tMin,
floor = Math.floor,
stringFromCharCode = String.fromCharCode,
/** Temporary variable */
key;
/*--------------------------------------------------------------------------*/
/**
* A generic error utility function.
* @private
* @param {String} type The error type.
* @returns {Error} Throws a `RangeError` with the applicable error message.
*/
function error(type) {
throw new RangeError(errors[type]);
}
/**
* A generic `Array#map` utility function.
* @private
* @param {Array} array The array to iterate over.
* @param {Function} callback The function that gets called for every array
* item.
* @returns {Array} A new array of values returned by the callback function.
*/
function map(array, fn) {
var length = array.length;
var result = [];
while (length--) {
result[length] = fn(array[length]);
}
return result;
}
/**
* A simple `Array#map`-like wrapper to work with domain name strings or email
* addresses.
* @private
* @param {String} domain The domain name or email address.
* @param {Function} callback The function that gets called for every
* character.
* @returns {Array} A new string of characters returned by the callback
* function.
*/
function mapDomain(string, fn) {
var parts = string.split('@');
var result = '';
if (parts.length > 1) {
// In email addresses, only the domain name should be punycoded. Leave
// the local part (i.e. everything up to `@`) intact.
result = parts[0] + '@';
string = parts[1];
}
// Avoid `split(regex)` for IE8 compatibility. See #17.
string = string.replace(regexSeparators, '\x2E');
var labels = string.split('.');
var encoded = map(labels, fn).join('.');
return result + encoded;
}
/**
* Creates an array containing the numeric code points of each Unicode
* character in the string. While JavaScript uses UCS-2 internally,
* this function will convert a pair of surrogate halves (each of which
* UCS-2 exposes as separate characters) into a single code point,
* matching UTF-16.
* @see `punycode.ucs2.encode`
* @see <https://mathiasbynens.be/notes/javascript-encoding>
* @memberOf punycode.ucs2
* @name decode
* @param {String} string The Unicode input string (UCS-2).
* @returns {Array} The new array of code points.
*/
function ucs2decode(string) {
var output = [],
counter = 0,
length = string.length,
value,
extra;
while (counter < length) {
value = string.charCodeAt(counter++);
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
// high surrogate, and there is a next character
extra = string.charCodeAt(counter++);
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
} else {
// unmatched surrogate; only append this code unit, in case the next
// code unit is the high surrogate of a surrogate pair
output.push(value);
counter--;
}
} else {
output.push(value);
}
}
return output;
}
/**
* Creates a string based on an array of numeric code points.
* @see `punycode.ucs2.decode`
* @memberOf punycode.ucs2
* @name encode
* @param {Array} codePoints The array of numeric code points.
* @returns {String} The new Unicode string (UCS-2).
*/
function ucs2encode(array) {
return map(array, function(value) {
var output = '';
if (value > 0xFFFF) {
value -= 0x10000;
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
value = 0xDC00 | value & 0x3FF;
}
output += stringFromCharCode(value);
return output;
}).join('');
}
/**
* Converts a basic code point into a digit/integer.
* @see `digitToBasic()`
* @private
* @param {Number} codePoint The basic numeric code point value.
* @returns {Number} The numeric value of a basic code point (for use in
* representing integers) in the range `0` to `base - 1`, or `base` if
* the code point does not represent a value.
*/
function basicToDigit(codePoint) {
if (codePoint - 48 < 10) {
return codePoint - 22;
}
if (codePoint - 65 < 26) {
return codePoint - 65;
}
if (codePoint - 97 < 26) {
return codePoint - 97;
}
return base;
}
/**
* Converts a digit/integer into a basic code point.
* @see `basicToDigit()`
* @private
* @param {Number} digit The numeric value of a basic code point.
* @returns {Number} The basic code point whose value (when used for
* representing integers) is `digit`, which needs to be in the range
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
* used; else, the lowercase form is used. The behavior is undefined
* if `flag` is non-zero and `digit` has no uppercase form.
*/
function digitToBasic(digit, flag) {
// 0..25 map to ASCII a..z or A..Z
// 26..35 map to ASCII 0..9
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
}
/**
* Bias adaptation function as per section 3.4 of RFC 3492.
* https://tools.ietf.org/html/rfc3492#section-3.4
* @private
*/
function adapt(delta, numPoints, firstTime) {
var k = 0;
delta = firstTime ? floor(delta / damp) : delta >> 1;
delta += floor(delta / numPoints);
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
delta = floor(delta / baseMinusTMin);
}
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
}
/**
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
* symbols.
* @memberOf punycode
* @param {String} input The Punycode string of ASCII-only symbols.
* @returns {String} The resulting string of Unicode symbols.
*/
function decode(input) {
// Don't use UCS-2
var output = [],
inputLength = input.length,
out,
i = 0,
n = initialN,
bias = initialBias,
basic,
j,
index,
oldi,
w,
k,
digit,
t,
/** Cached calculation results */
baseMinusT;
// Handle the basic code points: let `basic` be the number of input code
// points before the last delimiter, or `0` if there is none, then copy
// the first basic code points to the output.
basic = input.lastIndexOf(delimiter);
if (basic < 0) {
basic = 0;
}
for (j = 0; j < basic; ++j) {
// if it's not a basic code point
if (input.charCodeAt(j) >= 0x80) {
error('not-basic');
}
output.push(input.charCodeAt(j));
}
// Main decoding loop: start just after the last delimiter if any basic code
// points were copied; start at the beginning otherwise.
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
// `index` is the index of the next character to be consumed.
// Decode a generalized variable-length integer into `delta`,
// which gets added to `i`. The overflow checking is easier
// if we increase `i` as we go, then subtract off its starting
// value at the end to obtain `delta`.
for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
if (index >= inputLength) {
error('invalid-input');
}
digit = basicToDigit(input.charCodeAt(index++));
if (digit >= base || digit > floor((maxInt - i) / w)) {
error('overflow');
}
i += digit * w;
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
if (digit < t) {
break;
}
baseMinusT = base - t;
if (w > floor(maxInt / baseMinusT)) {
error('overflow');
}
w *= baseMinusT;
}
out = output.length + 1;
bias = adapt(i - oldi, out, oldi == 0);
// `i` was supposed to wrap around from `out` to `0`,
// incrementing `n` each time, so we'll fix that now:
if (floor(i / out) > maxInt - n) {
error('overflow');
}
n += floor(i / out);
i %= out;
// Insert `n` at position `i` of the output
output.splice(i++, 0, n);
}
return ucs2encode(output);
}
/**
* Converts a string of Unicode symbols (e.g. a domain name label) to a
* Punycode string of ASCII-only symbols.
* @memberOf punycode
* @param {String} input The string of Unicode symbols.
* @returns {String} The resulting Punycode string of ASCII-only symbols.
*/
function encode(input) {
var n,
delta,
handledCPCount,
basicLength,
bias,
j,
m,
q,
k,
t,
currentValue,
output = [],
/** `inputLength` will hold the number of code points in `input`. */
inputLength,
/** Cached calculation results */
handledCPCountPlusOne,
baseMinusT,
qMinusT;
// Convert the input in UCS-2 to Unicode
input = ucs2decode(input);
// Cache the length
inputLength = input.length;
// Initialize the state
n = initialN;
delta = 0;
bias = initialBias;
// Handle the basic code points
for (j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue < 0x80) {
output.push(stringFromCharCode(currentValue));
}
}
handledCPCount = basicLength = output.length;
// `handledCPCount` is the number of code points that have been handled;
// `basicLength` is the number of basic code points.
// Finish the basic string - if it is not empty - with a delimiter
if (basicLength) {
output.push(delimiter);
}
// Main encoding loop:
while (handledCPCount < inputLength) {
// All non-basic code points < n have been handled already. Find the next
// larger one:
for (m = maxInt, j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue >= n && currentValue < m) {
m = currentValue;
}
}
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
// but guard against overflow
handledCPCountPlusOne = handledCPCount + 1;
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
error('overflow');
}
delta += (m - n) * handledCPCountPlusOne;
n = m;
for (j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue < n && ++delta > maxInt) {
error('overflow');
}
if (currentValue == n) {
// Represent delta as a generalized variable-length integer
for (q = delta, k = base; /* no condition */; k += base) {
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
if (q < t) {
break;
}
qMinusT = q - t;
baseMinusT = base - t;
output.push(
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
);
q = floor(qMinusT / baseMinusT);
}
output.push(stringFromCharCode(digitToBasic(q, 0)));
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
delta = 0;
++handledCPCount;
}
}
++delta;
++n;
}
return output.join('');
}
/**
* Converts a Punycode string representing a domain name or an email address
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
* it doesn't matter if you call it on a string that has already been
* converted to Unicode.
* @memberOf punycode
* @param {String} input The Punycoded domain name or email address to
* convert to Unicode.
* @returns {String} The Unicode representation of the given Punycode
* string.
*/
function toUnicode(input) {
return mapDomain(input, function(string) {
return regexPunycode.test(string)
? decode(string.slice(4).toLowerCase())
: string;
});
}
/**
* Converts a Unicode string representing a domain name or an email address to
* Punycode. Only the non-ASCII parts of the domain name will be converted,
* i.e. it doesn't matter if you call it with a domain that's already in
* ASCII.
* @memberOf punycode
* @param {String} input The domain name or email address to convert, as a
* Unicode string.
* @returns {String} The Punycode representation of the given domain name or
* email address.
*/
function toASCII(input) {
return mapDomain(input, function(string) {
return regexNonASCII.test(string)
? 'xn--' + encode(string)
: string;
});
}
/*--------------------------------------------------------------------------*/
/** Define the public API */
punycode = {
/**
* A string representing the current Punycode.js version number.
* @memberOf punycode
* @type String
*/
'version': '1.3.2',
/**
* An object of methods to convert from JavaScript's internal character
* representation (UCS-2) to Unicode code points, and back.
* @see <https://mathiasbynens.be/notes/javascript-encoding>
* @memberOf punycode
* @type Object
*/
'ucs2': {
'decode': ucs2decode,
'encode': ucs2encode
},
'decode': decode,
'encode': encode,
'toASCII': toASCII,
'toUnicode': toUnicode
};
/** Expose `punycode` */
// Some AMD build optimizers, like r.js, check for specific condition patterns
// like the following:
if (
typeof define == 'function' &&
typeof define.amd == 'object' &&
define.amd
) {
define('punycode', function() {
return punycode;
});
} else if (freeExports && freeModule) {
if (module.exports == freeExports) {
// in Node.js, io.js, or RingoJS v0.8.0+
freeModule.exports = punycode;
} else {
// in Narwhal or RingoJS v0.7.0-
for (key in punycode) {
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
}
}
} else {
// in Rhino or a web browser
root.punycode = punycode;
}
}(this));

26
test/index.html Normal file
View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>URI Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<link rel="stylesheet" href="qunit/qunit-composite.css" type="text/css" media="screen">
<script type="text/javascript" src="qunit/qunit.js"></script>
<script type="text/javascript" src="qunit/qunit-composite.js"></script>
<script>
QUnit.testSuites([
"test.URI.html",
"test.jQuery-1.10.html",
"test.jQuery-1.9.html",
"test.jQuery-1.8.html",
"test.jQuery-1.7.html",
"test.fragmentQuery.html",
"test.fragmentURI.html"
]);
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

7
test/pre_libs.js Normal file
View File

@ -0,0 +1,7 @@
/*global window */
// FIXME: v2.0.0 renamce non-camelCase properties to uppercase
/*jshint camelcase: false */
window.URI = window.URI_pre_lib = 'original URI, before loading URI.js library';
window.URITemplate = window.URITemplate_pre_lib = 'original URITemplate, before loading URI.js library';
window.IPv6 = window.IPv6_pre_lib = 'original IPv6, before loading URI.js library';
window.SecondLevelDomains = window.SecondLevelDomains_pre_lib = 'original SecondLevelDomains, before loading URI.js library';

View File

@ -0,0 +1,13 @@
.qunit-composite-suite {
position: fixed;
bottom: 0;
left: 0;
margin: 0;
padding: 0;
border-width: 1px 0 0;
height: 45%;
width: 100%;
background: #fff;
}

View File

@ -0,0 +1,167 @@
/**
* JUnit reporter for QUnit v1.0.1
*
* https://github.com/jquery/qunit-composite
*
* Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license.
* https://jquery.org/license/
*/
(function( QUnit ) {
var iframe, hasBound, addClass,
modules = 1,
executingComposite = false;
// TODO: Kill this fallback method once QUnit 1.12 is released
addClass = typeof QUnit.addClass === "function" ?
QUnit.addClass :
(function() {
var hasClass = typeof QUnit.hasClass === "function" ?
QUnit.hasClass :
function hasClass( elem, name ) {
return ( " " + elem.className + " " ).indexOf( " " + name + " " ) > -1;
};
return function addClass( elem, name ) {
if ( !hasClass( elem, name ) ) {
elem.className += ( elem.className ? " " : "" ) + name;
}
};
})();
function runSuite( suite ) {
var path;
if ( QUnit.is( "object", suite ) ) {
path = suite.path;
suite = suite.name;
} else {
path = suite;
}
QUnit.asyncTest( suite, function() {
iframe.setAttribute( "src", path );
// QUnit.start is called from the child iframe's QUnit.done hook.
});
}
function initIframe() {
var iframeWin,
body = document.body;
function onIframeLoad() {
var moduleName, testName,
count = 0;
if ( !iframe.src ) {
return;
}
iframeWin.QUnit.moduleStart(function( data ) {
// Capture module name for messages
moduleName = data.name;
});
iframeWin.QUnit.testStart(function( data ) {
// Capture test name for messages
testName = data.name;
});
iframeWin.QUnit.testDone(function() {
testName = undefined;
});
iframeWin.QUnit.log(function( data ) {
if (testName === undefined) {
return;
}
// Pass all test details through to the main page
var message = ( moduleName ? moduleName + ": " : "" ) + testName + ": " + ( data.message || ( data.result ? "okay" : "failed" ) );
expect( ++count );
QUnit.push( data.result, data.actual, data.expected, message );
});
// Continue the outer test when the iframe's test is done
iframeWin.QUnit.done( QUnit.start );
}
iframe = document.createElement( "iframe" );
iframe.className = "qunit-composite-suite";
body.appendChild( iframe );
QUnit.addEvent( iframe, "load", onIframeLoad );
iframeWin = iframe.contentWindow;
}
/**
* @param {string} [name] Module name to group these test suites.
* @param {Array} suites List of suites where each suite
* may either be a string (path to the html test page),
* or an object with a path and name property.
*/
QUnit.testSuites = function( name, suites ) {
var i, suitesLen;
if ( arguments.length === 1 ) {
suites = name;
name = "Composition #" + modules++;
}
suitesLen = suites.length;
if ( !hasBound ) {
hasBound = true;
QUnit.begin( initIframe );
// TODO: Would be better to use something like QUnit.once( 'moduleDone' )
// after the last test suite.
QUnit.moduleDone( function () {
executingComposite = false;
} );
QUnit.done(function() {
iframe.style.display = "none";
});
}
QUnit.module( name, {
setup: function () {
executingComposite = true;
}
});
for ( i = 0; i < suitesLen; i++ ) {
runSuite( suites[ i ] );
}
};
QUnit.testDone(function() {
if ( !executingComposite ) {
return;
}
var i, len,
current = QUnit.id( this.config.current.id ),
children = current.children,
src = iframe.src;
QUnit.addEvent( current, "dblclick", function( e ) {
var target = e && e.target ? e.target : window.event.srcElement;
if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) {
target = target.parentNode;
}
if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
window.location = src;
}
});
// Undo QUnit's auto-expansion for bad tests
for ( i = 0, len = children.length; i < len; i++ ) {
if ( children[ i ].nodeName.toLowerCase() === "ol" ) {
addClass( children[ i ], "qunit-collapsed" );
}
}
// Update Rerun link to point to the standalone test suite page
current.getElementsByTagName( "a" )[ 0 ].href = src;
});
})( QUnit );

244
test/qunit/qunit.css Normal file
View File

@ -0,0 +1,244 @@
/**
* QUnit v1.12.0 - A JavaScript Unit Testing Framework
*
* http://qunitjs.com
*
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
/** Font Family and Sizes */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
#qunit-tests { font-size: smaller; }
/** Resets */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
margin: 0;
padding: 0;
}
/** Header */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699a4;
background-color: #0d3349;
font-size: 1.5em;
line-height: 1em;
font-weight: normal;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-top-right-radius: 5px;
-webkit-border-top-left-radius: 5px;
}
#qunit-header a {
text-decoration: none;
color: #c2ccd1;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #fff;
}
#qunit-testrunner-toolbar label {
display: inline-block;
padding: 0 .5em 0 .1em;
}
#qunit-banner {
height: 5px;
}
#qunit-testrunner-toolbar {
padding: 0.5em 0 0.5em 2em;
color: #5E740B;
background-color: #eee;
overflow: hidden;
}
#qunit-userAgent {
padding: 0.5em 0 0.5em 2.5em;
background-color: #2b81af;
color: #fff;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
#qunit-modulefilter-container {
float: right;
}
/** Tests: Pass/Fail */
#qunit-tests {
list-style-position: inside;
}
#qunit-tests li {
padding: 0.4em 0.5em 0.4em 2.5em;
border-bottom: 1px solid #fff;
list-style-position: inside;
}
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
display: none;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li a {
padding: 0.5em;
color: #c2ccd1;
text-decoration: none;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
}
#qunit-tests li .runtime {
float: right;
font-size: smaller;
}
.qunit-assert-list {
margin-top: 0.5em;
padding: 0.5em;
background-color: #fff;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
.qunit-collapsed {
display: none;
}
#qunit-tests table {
border-collapse: collapse;
margin-top: .2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 .5em 0 0;
}
#qunit-tests td {
vertical-align: top;
}
#qunit-tests pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
#qunit-tests del {
background-color: #e0f2be;
color: #374e0c;
text-decoration: none;
}
#qunit-tests ins {
background-color: #ffcaca;
color: #500;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: black; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
padding: 5px;
background-color: #fff;
border-bottom: none;
list-style-position: inside;
}
/*** Passing Styles */
#qunit-tests li li.pass {
color: #3c510c;
background-color: #fff;
border-left: 10px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
/*** Failing Styles */
#qunit-tests li li.fail {
color: #710909;
background-color: #fff;
border-left: 10px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
}
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: green; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/** Result */
#qunit-testresult {
padding: 0.5em 0.5em 0.5em 2.5em;
color: #2b81af;
background-color: #D2E0E6;
border-bottom: 1px solid white;
}
#qunit-testresult .module-name {
font-weight: bold;
}
/** Fixture */
#qunit-fixture {
position: absolute;
top: -10000px;
left: -10000px;
width: 1000px;
height: 1000px;
}

2212
test/qunit/qunit.js Normal file

File diff suppressed because it is too large Load Diff

26
test/test.URI.html Normal file
View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>URI.js - URI Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="pre_libs.js"></script>
<script type="text/javascript" src="../src/punycode.js"></script>
<script type="text/javascript" src="../src/IPv6.js"></script>
<script type="text/javascript" src="../src/SecondLevelDomains.js"></script>
<script type="text/javascript" src="../src/URI.js"></script>
<script type="text/javascript" src="../src/URITemplate.js"></script>
<script type="text/javascript" src="../jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../src/jquery.URI.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<script type="text/javascript" src="urls.js"></script>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="test_jim.js"></script>
<script type="text/javascript" src="test_template.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>fragmentQuery - URI Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="pre_libs.js"></script>
<script type="text/javascript" src="../src/punycode.js"></script>
<script type="text/javascript" src="../src/IPv6.js"></script>
<script type="text/javascript" src="../src/SecondLevelDomains.js"></script>
<script type="text/javascript" src="../src/URI.js"></script>
<script type="text/javascript" src="../src/URITemplate.js"></script>
<script type="text/javascript" src="../src/URI.fragmentQuery.js"></script>
<script type="text/javascript" src="../jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<!--
as the plugins alter core URI functionality,
it is necessary to re-test URI itself was well
-->
<script type="text/javascript" src="urls.js"></script>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="test_jim.js"></script>
<script type="text/javascript" src="test_template.js"></script>
<script type="text/javascript" src="test_fragmentQuery.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>fragmentURI - URI Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="pre_libs.js"></script>
<script type="text/javascript" src="../src/punycode.js"></script>
<script type="text/javascript" src="../src/IPv6.js"></script>
<script type="text/javascript" src="../src/SecondLevelDomains.js"></script>
<script type="text/javascript" src="../src/URI.js"></script>
<script type="text/javascript" src="../src/URITemplate.js"></script>
<script type="text/javascript" src="../src/URI.fragmentURI.js"></script>
<script type="text/javascript" src="../jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<!--
as the plugins alter core URI functionality,
it is necessary to re-test URI itself was well
-->
<script type="text/javascript" src="urls.js"></script>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="test_jim.js"></script>
<script type="text/javascript" src="test_template.js"></script>
<script type="text/javascript" src="test_fragmentURI.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>jQuery Plugin 1.10 - URI Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="pre_libs.js"></script>
<script type="text/javascript" src="../src/punycode.js"></script>
<script type="text/javascript" src="../src/IPv6.js"></script>
<script type="text/javascript" src="../src/SecondLevelDomains.js"></script>
<script type="text/javascript" src="../src/URI.js"></script>
<script type="text/javascript" src="../src/URITemplate.js"></script>
<script type="text/javascript" src="../jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../src/jquery.URI.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<!--
as the plugins alter core URI functionality,
it is necessary to re-test URI itself was well
-->
<script type="text/javascript" src="urls.js"></script>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="test_jim.js"></script>
<script type="text/javascript" src="test_template.js"></script>
<script type="text/javascript" src="test_jquery.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

31
test/test.jQuery-1.7.html Normal file
View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>jQuery Plugin 1.7 - URI Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="pre_libs.js"></script>
<script type="text/javascript" src="../src/punycode.js"></script>
<script type="text/javascript" src="../src/IPv6.js"></script>
<script type="text/javascript" src="../src/SecondLevelDomains.js"></script>
<script type="text/javascript" src="../src/URI.js"></script>
<script type="text/javascript" src="../src/URITemplate.js"></script>
<script type="text/javascript" src="../jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../src/jquery.URI.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<!--
as the plugins alter core URI functionality,
it is necessary to re-test URI itself was well
-->
<script type="text/javascript" src="urls.js"></script>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="test_jim.js"></script>
<script type="text/javascript" src="test_template.js"></script>
<script type="text/javascript" src="test_jquery.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

31
test/test.jQuery-1.8.html Normal file
View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>jQuery Plugin 1.8 - URI Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="pre_libs.js"></script>
<script type="text/javascript" src="../src/punycode.js"></script>
<script type="text/javascript" src="../src/IPv6.js"></script>
<script type="text/javascript" src="../src/SecondLevelDomains.js"></script>
<script type="text/javascript" src="../src/URI.js"></script>
<script type="text/javascript" src="../src/URITemplate.js"></script>
<script type="text/javascript" src="../jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../src/jquery.URI.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<!--
as the plugins alter core URI functionality,
it is necessary to re-test URI itself was well
-->
<script type="text/javascript" src="urls.js"></script>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="test_jim.js"></script>
<script type="text/javascript" src="test_template.js"></script>
<script type="text/javascript" src="test_jquery.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

31
test/test.jQuery-1.9.html Normal file
View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>jQuery Plugin 1.9 - URI Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="pre_libs.js"></script>
<script type="text/javascript" src="../src/punycode.js"></script>
<script type="text/javascript" src="../src/IPv6.js"></script>
<script type="text/javascript" src="../src/SecondLevelDomains.js"></script>
<script type="text/javascript" src="../src/URI.js"></script>
<script type="text/javascript" src="../src/URITemplate.js"></script>
<script type="text/javascript" src="../jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../src/jquery.URI.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<!--
as the plugins alter core URI functionality,
it is necessary to re-test URI itself was well
-->
<script type="text/javascript" src="urls.js"></script>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="test_jim.js"></script>
<script type="text/javascript" src="test_template.js"></script>
<script type="text/javascript" src="test_jquery.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

1837
test/test.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,59 @@
(function() {
'use strict';
/*global URI, test, equal, deepEqual */
module('URI.fragmentQuery');
test('storing query-data in fragment', function() {
var u = URI('http://example.org');
deepEqual(u.fragment(true), {}, 'empty map for missing fragment');
u = URI('http://example.org/#');
deepEqual(u.fragment(true), {}, 'empty map for empty fragment');
u = URI('http://example.org/#?hello=world');
deepEqual(u.fragment(true), {hello: 'world'}, 'reading data object');
u.fragment({bar: 'foo'});
deepEqual(u.fragment(true), {bar: 'foo'}, 'setting data object');
equal(u.toString(), 'http://example.org/#?bar=foo', 'setting data object serialized');
u.addFragment('name', 'value');
deepEqual(u.fragment(true), {bar: 'foo', name: 'value'}, 'adding value');
equal(u.toString(), 'http://example.org/#?bar=foo&name=value', 'adding value serialized');
u.removeFragment('bar');
deepEqual(u.fragment(true), {name: 'value'}, 'removing value bar');
equal(u.toString(), 'http://example.org/#?name=value', 'removing value bar serialized');
u.removeFragment('name');
deepEqual(u.fragment(true), {}, 'removing value name');
equal(u.toString(), 'http://example.org/#?', 'removing value name serialized');
});
test('fragmentPrefix', function() {
var u;
URI.fragmentPrefix = '!';
u = URI('http://example.org');
equal(u._parts.fragmentPrefix, '!', 'init using global property');
u.fragment('#?hello=world');
equal(u.fragment(), '?hello=world', 'unparsed ?');
deepEqual(u.fragment(true), {}, 'parsing ? prefix');
u.fragment('#!hello=world');
equal(u.fragment(), '!hello=world', 'unparsed !');
deepEqual(u.fragment(true), {hello: 'world'}, 'parsing ! prefix');
u.fragmentPrefix('§');
equal(u.fragment(), '!hello=world', 'unparsed §');
deepEqual(u.fragment(true), {}, 'parsing § prefix');
u.fragment('#§hello=world');
equal(u.fragment(), '§hello=world', 'unparsed §');
deepEqual(u.fragment(true), {hello: 'world'}, 'parsing § prefix');
URI.fragmentPrefix = '?';
});
})();

61
test/test_fragmentURI.js Normal file
View File

@ -0,0 +1,61 @@
(function() {
'use strict';
/*global URI, test, equal, ok */
module('URI.fragmentURI');
test('storing URLs in fragment', function() {
var u = URI('http://example.org');
var f;
// var uri = URI('http://example.org/#!/foo/bar/baz.html');
// var furi = uri.fragment(true);
// furi.pathname() === '/foo/bar/baz.html';
// furi.pathname('/hello.html');
// uri.toString() === 'http://example.org/#!/hello.html'
ok(u.fragment(true) instanceof URI, 'URI instance for missing fragment');
u = URI('http://example.org/#');
ok(u.fragment(true) instanceof URI, 'URI instance for empty fragment');
u = URI('http://example.org/#!/foo/bar/baz.html');
f = u.fragment(true);
equal(f.pathname(), '/foo/bar/baz.html', 'reading path of FragmentURI');
equal(f.filename(), 'baz.html', 'reading filename of FragmentURI');
f.filename('foobar.txt');
equal(f.pathname(), '/foo/bar/foobar.txt', 'modifying filename of FragmentURI');
equal(u.fragment(), '!/foo/bar/foobar.txt', 'modifying fragment() through FragmentURI on original');
equal(u.toString(), 'http://example.org/#!/foo/bar/foobar.txt', 'modifying filename of FragmentURI on original');
});
test('fragmentPrefix', function() {
var u;
URI.fragmentPrefix = '?';
u = URI('http://example.org');
equal(u._parts.fragmentPrefix, '?', 'init using global property');
u.fragment('#!/foo/bar/baz.html');
equal(u.fragment(), '!/foo/bar/baz.html', 'unparsed ?');
ok(u.fragment(true) instanceof URI, 'parsing ? prefix - is URI');
equal(u.fragment(true).toString(), '', 'parsing ? prefix - result');
u.fragment('#?/foo/bar/baz.html');
equal(u.fragment(), '?/foo/bar/baz.html', 'unparsed ?');
ok(u.fragment(true) instanceof URI, 'parsing ? prefix - is URI');
equal(u.fragment(true).toString(), '/foo/bar/baz.html', 'parsing ? prefix - result');
u.fragmentPrefix('§');
equal(u.fragment(), '?/foo/bar/baz.html', 'unparsed §');
ok(u.fragment(true) instanceof URI, 'parsing § prefix - is URI');
equal(u.fragment(true).toString(), '', 'parsing § prefix - result');
u.fragment('#§/foo/bar/baz.html');
equal(u.fragment(), '§/foo/bar/baz.html', 'unparsed §');
ok(u.fragment(true) instanceof URI, 'parsing § prefix - is URI');
equal(u.fragment(true).toString(), '/foo/bar/baz.html', 'parsing § prefix - result');
URI.fragmentPrefix = '!';
});
})();

146
test/test_jim.js Normal file
View File

@ -0,0 +1,146 @@
/*
* What would jim do?
* more tests for border-edge cases
* Christian Harms.
*
* Note: I have no clue who or what jim is supposed to be. It might be something like the German DAU (dumbest possible user)
*/
(function() {
'use strict';
/*global URI, test, equal, raises */
module('injection');
test('protocol', function() {
var u = new URI('http://example.com/dir1/dir2/?query1=value1&query2=value2#hash');
raises(function() {
u.protocol('ftp://example.org');
}, TypeError, 'Failing invalid characters');
u.protocol('ftp:');
equal(u.protocol(), 'ftp', 'protocol() has set invalid protocoll!');
equal(u.hostname(), 'example.com', 'protocol() has changed the hostname');
});
test('port', function() {
var u = new URI('http://example.com/dir1/dir2/?query1=value1&query2=value2#hash');
raises(function() {
u.port('99:example.org');
}, TypeError, 'Failing invalid characters');
u.port(':99');
equal(u.hostname(), 'example.com', 'port() has modified hostname');
equal(u.port(), 99, 'port() has set an invalid port');
u.port(false);
equal(u.port(), '', 'port() has set an invalid port');
// RFC 3986 says nothing about "16-bit unsigned" http://tools.ietf.org/html/rfc3986#section-3.2.3
// u.href(new URI("http://example.com/"))
// u.port(65536);
// notEqual(u.port(), "65536", "port() has set to an non-valid value (A port number is a 16-bit unsigned integer)");
raises(function() {
u.port('-99');
}, TypeError, 'Failing invalid characters');
});
test('domain', function() {
var u = new URI('http://example.com/dir1/dir2/?query1=value1&query2=value2#hash');
raises(function() {
u.domain('example.org/dir0/');
}, TypeError, 'Failing invalid characters');
raises(function() {
u.domain('example.org:80');
}, TypeError, 'Failing invalid characters');
raises(function() {
u.domain('foo@example.org');
}, TypeError, 'Failing invalid characters');
});
test('subdomain', function() {
var u = new URI('http://example.com/dir1/dir2/?query1=value1&query2=value2#hash');
raises(function() {
u.subdomain('example.org/dir0/');
}, TypeError, 'Failing invalid characters');
raises(function() {
u.subdomain('example.org:80');
}, TypeError, 'Failing invalid characters');
raises(function() {
u.subdomain('foo@example.org');
}, TypeError, 'Failing invalid characters');
});
test('tld', function() {
var u = new URI('http://example.com/dir1/dir2/?query1=value1&query2=value2#hash');
raises(function() {
u.tld('foo/bar.html');
}, TypeError, 'Failing invalid characters');
});
test('path', function() {
var u = new URI('http://example.com/dir1/dir2/?query1=value1&query2=value2#hash');
u.path('/dir3/?query3=value3#fragment');
equal(u.hostname(), 'example.com', 'path() has modified hostname');
equal(u.path(), '/dir3/%3Fquery3=value3%23fragment', 'path() has set invalid path');
equal(u.query(), 'query1=value1&query2=value2', 'path() has modified query');
equal(u.fragment(), 'hash', 'path() has modified fragment');
});
test('filename', function() {
var u = new URI('http://example.com/dir1/dir2/?query1=value1&query2=value2#hash');
u.filename('name.html?query');
equal(u.filename(), 'name.html%3Fquery', 'filename() has set invalid filename');
equal(u.query(), 'query1=value1&query2=value2', 'filename() has modified query');
// allowed!
u.filename('../name.html?query');
equal(u.filename(), 'name.html%3Fquery', 'filename() has set invalid filename');
equal(u.directory(), '/dir1', 'filename() has not altered directory properly');
});
test('addQuery', function() {
var u = new URI('http://example.com/dir1/dir2/?query1=value1&query2=value2#hash');
u.addQuery('query3', 'value3#got');
equal(u.query(), 'query1=value1&query2=value2&query3=value3%23got', 'addQuery() has set invalid query');
equal(u.fragment(), 'hash', 'addQuery() has modified fragment');
});
/*
// RFC 3986 says "…and should limit these names to no more than 255 characters in length."
// SHOULD is not MUST therefore not the responsibility of URI.js
module("validation");
test("domain", function() {
// this bases on the wiki page information: http://en.wikipedia.org/wiki/Domain_Name_System
var u = new URI("http://example.com/"), domain, i, j;
//generate a 204 character domain
domain = "com"
for (i=0; i<20; i++) {
domain = "0123456789." + domain;
}
u.domain(domain);
equals(u.hostname(), domain, "domain() has not set 204-character-domain");
//expand the domain to a 404 character domain
for (i=0; i<20; i++) {
domain = "0123456789." + domain;
}
u.domain(domain);
equals(u.hostname() == domain, true, "set domain() with "+domain.length+" charachters - not valid domainname");
//generate a domain with three 70-char subdomains-parts.
domain = "com";
for (j=0; j<3; j++) {
//start new subdomain
domain = "." + domain;
for (i=0; i<70; i++) {
domain = "a" + domain;
}
}
u.domain(domain);
equals(u.hostname() == domain, true, "set domain() with 70-character subdomain not valid domainname");
});
*/
})();

141
test/test_jquery.js Normal file
View File

@ -0,0 +1,141 @@
(function() {
'use strict';
/*global document, URI, $, test, equal, ok */
module('jQuery.URI', {
setup: function() {
var links = [
'<a href="http://example.org/">an HTTP link</a>',
'<a href="https://example.org/">an HTTPS link</a>',
'<a href="http://example.org/so)me.pdf">some pdf</a>',
'<a href="http://example.org/hello/world.html">hello world</a>',
'<a href="ftp://localhost/one/two/three/file.ext">directories</a>',
'<a href="ftp://localhost/one/two/file.ext">directories</a>',
'<a href="mailto:mail@example.org?subject=Hello+World">Mail me</a>',
'<a href="javascript:alert(\'ugly!\');">some javascript</a>',
'<a href="#anchor">jump to anchor</a>',
'<img src="/dontexist.jpg" alt="some jpeg">',
'<img src="/dontexist.svg" alt="some svg">',
'<form method="post" action="/some/script.php"></form>'
];
$('<div id="testestest">' + links.join('') + '</div>')
.appendTo(document.body);
$('<div>foo</div>')
.appendTo(document.body);
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '/nonexistant.js';
document.getElementById('testestest').appendChild(script);
},
teardown: function() {
var t = $('#testestest');
t.next().remove();
t.remove();
}
});
test('.uri()', function() {
var $links = $('#testestest'),
$first = $links.children().first(),
uri = $first.uri(),
_uri = URI('/hello.world');
ok(uri !== _uri, 'different URI instances');
var __uri = $first.uri(_uri);
ok(uri !== _uri, 'different URI instances');
ok(uri === __uri, 'same URI instances');
equal($first.attr('href'), _uri.toString(), 'equal URI');
});
test('filtering with :uri()', function() {
var $links = $('#testestest');
// find using accessor and "begins with" comparison
equal($('a:uri(href^=#anc)').length, 1, '$(selector) Anchor Link');
equal($links.find(':uri(href^=#anc)').length, 1, '.find(selector) Anchor Link');
// find using accessor and "ends with" comparison
equal($(':uri(href$=.css)').length, 1, ':uri(href$=.css)');
// find using accessor and "contains" comparison
equal($(':uri(href *= /hello/)').length, 1, ':uri(href *= /hello/)');
// find using accessor and "equals" comparison
equal($links.find(':uri(protocol=https)').length, 1, ':uri(protocol=https)');
equal($links.find(':uri(protocol=http)').length, 3, ':uri(protocol=http)');
// directory match with trailing slash
equal($links.find(':uri(directory *= /two/)').length, 2, ':uri(directory *= /two/)');
// find using URI.is()
equal($links.find(':uri(relative)').length, 5, ':uri(relative)');
equal($links.find(':uri(is:relative)').length, 5, ':uri(is:relative)');
equal($links.find(':uri(is: relative)').length, 5, ':uri(is:relative)');
// find using URI.equal()
// This syntax breaks Sizzle, probably because it's looking for a nested pseudo ":http"
//equal($links.find(':uri(equals:http://example.org/hello/foo/../world.html)').length, 1, ':uri(equals:$url$)');
equal($links.find(':uri(equals:"http://example.org/hello/foo/../world.html")').length, 1, ':uri(equals:$url$)');
equal($links.find(':uri(equals: "http://example.org/hello/foo/../world.html")').length, 1, ':uri(equals:$url$)');
// find URNs
equal($links.find(':uri(urn)').length, 2, ':uri(urn)');
// .is()
equal($links.children('script').is(':uri(suffix=js)'), true, '.is(\':uri(suffix=js)\')');
equal($links.children('form').is(':uri(suffix=php)'), true, '.is(\':uri(suffix=php)\')');
// .has()
equal($('div').has(':uri(suffix=js)').length, 1, '.has(\':uri(suffix=js)\')');
});
test('.attr("href")', function() {
var $links = $('#testestest'),
$first = $links.children().first(),
first = $first.get(0),
uri = $first.uri(),
href = function(elem) {
return elem.getAttribute('href');
};
if (!$.support.hrefNormalized) {
href = function(elem) {
return elem.getAttribute('href', 2);
};
}
ok(uri instanceof URI, 'instanceof URI');
equal(href(first), uri.toString(), 'URI equals href');
// test feedback to DOM element
uri.hostname('example.com');
ok($first.uri() === uri, 'URI persisted');
equal(href(first), uri.toString(), 'transparent href update');
// test feedback from DOM element
$first.attr('href', 'http://example.net/');
ok($first.uri() === uri, 'URI persisted');
equal(href(first), uri.toString(), 'transparent href update');
});
test('.attr("uri:accessor")', function() {
var $links = $('#testestest'),
$first = $links.children().first(),
uri = $first.uri(),
href = function(elem) {
return elem.getAttribute('href');
};
if (!$.support.hrefNormalized) {
href = function(elem) {
return elem.getAttribute('href', 2);
};
}
equal($first.attr('uri:hostname'), 'example.org', 'reading uri:hostname');
$first.attr('uri:hostname', 'example.com');
equal($first.attr('uri:hostname'), 'example.com', 'changed uri:hostname');
equal($first.is(':uri(hostname=example.com)'), true, ':uri() after changed uri:hostname');
ok($first.uri() === uri, 'URI persisted');
});
})();

411
test/test_template.js Normal file
View File

@ -0,0 +1,411 @@
(function() {
'use strict';
/*global window, URITemplate, URITemplate_pre_lib, test, equal, strictEqual, raises */
// FIXME: v2.0.0 renamce non-camelCase properties to uppercase
/*jshint camelcase: false, loopfunc: true, newcap: false */
var levels = {
// http://tools.ietf.org/html/rfc6570#section-1.2
'Level 1' : {
expressions : {
'Simple string expansion' : {
'{var}' : 'value',
'{hello}' : 'Hello%20World%21'
}
},
values : {
'var' : 'value',
'hello' : 'Hello World!'
}
},
'Level 2' : {
expressions : {
'Reserved string expansion' : {
'{+var}' : 'value',
'{+hello}' : 'Hello%20World!',
'{+path}/here' : '/foo/bar/here',
'here?ref={+path}' : 'here?ref=/foo/bar'
},
'Fragment expansion, crosshatch-prefixed' : {
'X{#var}' : 'X#value',
'X{#hello}' : 'X#Hello%20World!'
}
},
values : {
'var' : 'value',
'hello' : 'Hello World!',
'path' : '/foo/bar'
}
},
'Level 3' : {
expressions : {
'String expansion with multiple variables' : {
'map?{x,y}' : 'map?1024,768',
'{x,hello,y}' : '1024,Hello%20World%21,768'
},
'Reserved expansion with multiple variables' : {
'{+x,hello,y}' : '1024,Hello%20World!,768',
'{+path,x}/here' : '/foo/bar,1024/here'
},
'Fragment expansion with multiple variables' : {
'{#x,hello,y}' : '#1024,Hello%20World!,768',
'{#path,x}/here' : '#/foo/bar,1024/here'
},
'Label expansion, dot-prefixed' : {
'X{.var}' : 'X.value',
'X{.x,y}' : 'X.1024.768'
},
'Path segments, slash-prefixed' : {
'{/var}' : '/value',
'{/var,x}/here' : '/value/1024/here'
},
'Path-style parameters, semicolon-prefixed' : {
'{;x,y}' : ';x=1024;y=768',
'{;x,y,empty}' : ';x=1024;y=768;empty'
},
'Form-style query, ampersand-separated' : {
'{?x,y}' : '?x=1024&y=768',
'{?x,y,empty}' : '?x=1024&y=768&empty='
},
'Form-style query continuation' : {
'?fixed=yes{&x}' : '?fixed=yes&x=1024',
'{&x,y,empty}' : '&x=1024&y=768&empty='
}
},
values : {
'var' : 'value',
'hello' : 'Hello World!',
'empty' : '',
'path' : '/foo/bar',
'x' : '1024',
'y' : '768'
}
},
'Level 4' : {
expressions : {
'String expansion with value modifiers' : {
'{var:3}' : 'val',
'{var:30}' : 'value',
'{list}' : 'red,green,blue',
'{list*}' : 'red,green,blue',
'{keys}' : 'semi,%3B,dot,.,comma,%2C',
'{keys*}' : 'semi=%3B,dot=.,comma=%2C'
},
'Reserved expansion with value modifiers' : {
'{+path:6}/here' : '/foo/b/here',
'{+list}' : 'red,green,blue',
'{+list*}' : 'red,green,blue',
'{+keys}' : 'semi,;,dot,.,comma,,',
'{+keys*}' : 'semi=;,dot=.,comma=,'
},
'Fragment expansion with value modifiers' : {
'{#path:6}/here' : '#/foo/b/here',
'{#list}' : '#red,green,blue',
'{#list*}' : '#red,green,blue',
'{#keys}' : '#semi,;,dot,.,comma,,',
'{#keys*}' : '#semi=;,dot=.,comma=,'
},
'Label expansion, dot-prefixed' : {
'X{.var:3}' : 'X.val',
'X{.list}' : 'X.red,green,blue',
'X{.list*}' : 'X.red.green.blue',
'X{.keys}' : 'X.semi,%3B,dot,.,comma,%2C',
'X{.keys*}' : 'X.semi=%3B.dot=..comma=%2C'
},
'Path segments, slash-prefixed' : {
'{/var:1,var}' : '/v/value',
'{/list}' : '/red,green,blue',
'{/list*}' : '/red/green/blue',
'{/list*,path:4}' : '/red/green/blue/%2Ffoo',
'{/keys}' : '/semi,%3B,dot,.,comma,%2C',
'{/keys*}' : '/semi=%3B/dot=./comma=%2C'
},
'Path-style parameters, semicolon-prefixed' : {
'{;hello:5}' : ';hello=Hello',
'{;list}' : ';list=red,green,blue',
'{;list*}' : ';list=red;list=green;list=blue',
'{;keys}' : ';keys=semi,%3B,dot,.,comma,%2C',
'{;keys*}' : ';semi=%3B;dot=.;comma=%2C'
},
'Form-style query, ampersand-separated' : {
'{?var:3}' : '?var=val',
'{?list}' : '?list=red,green,blue',
'{?list*}' : '?list=red&list=green&list=blue',
'{?keys}' : '?keys=semi,%3B,dot,.,comma,%2C',
'{?keys*}' : '?semi=%3B&dot=.&comma=%2C'
},
'Form-style query continuation' : {
'{&var:3}' : '&var=val',
'{&list}' : '&list=red,green,blue',
'{&list*}' : '&list=red&list=green&list=blue',
'{&keys}' : '&keys=semi,%3B,dot,.,comma,%2C',
'{&keys*}' : '&semi=%3B&dot=.&comma=%2C'
}
},
values : {
'var' : 'value',
'hello' : 'Hello World!',
'path' : '/foo/bar',
'list' : ['red', 'green', 'blue'],
'keys' : {
'semi' : ';',
'dot' : '.',
'comma' : ','
}
}
},
// http://tools.ietf.org/html/rfc6570#section-3
'Expression Expansion' : {
expressions : {
'Variable Expansion' : {
'{count}' : 'one,two,three',
'{count*}' : 'one,two,three',
'{/count}' : '/one,two,three',
'{/count*}' : '/one/two/three',
'{;count}' : ';count=one,two,three',
'{;count*}' : ';count=one;count=two;count=three',
'{?count}' : '?count=one,two,three',
'{?count*}' : '?count=one&count=two&count=three',
'{&count*}' : '&count=one&count=two&count=three'
},
'Simple String Expansion' : {
'{var}' : 'value',
'{hello}' : 'Hello%20World%21',
'{half}' : '50%25',
'O{empty}X' : 'OX',
'O{undef}X' : 'OX',
'{x,y}' : '1024,768',
'{x,hello,y}' : '1024,Hello%20World%21,768',
'?{x,empty}' : '?1024,',
'?{x,undef}' : '?1024',
'?{undef,y}' : '?768',
'{var:3}' : 'val',
'{var:30}' : 'value',
'{list}' : 'red,green,blue',
'{list*}' : 'red,green,blue',
'{keys}' : 'semi,%3B,dot,.,comma,%2C',
'{keys*}' : 'semi=%3B,dot=.,comma=%2C'
},
'Reserved Expansion' : {
'{+var}' : 'value',
'{+hello}' : 'Hello%20World!',
'{+half}' : '50%25',
'{base}index' : 'http%3A%2F%2Fexample.com%2Fhome%2Findex',
'{+base}index' : 'http://example.com/home/index',
'O{+empty}X' : 'OX',
'O{+undef}X' : 'OX',
'{+path}/here' : '/foo/bar/here',
'here?ref={+path}' : 'here?ref=/foo/bar',
'up{+path}{var}/here' : 'up/foo/barvalue/here',
'{+x,hello,y}' : '1024,Hello%20World!,768',
'{+path,x}/here' : '/foo/bar,1024/here',
'{+path:6}/here' : '/foo/b/here',
'{+list}' : 'red,green,blue',
'{+list*}' : 'red,green,blue',
'{+keys}' : 'semi,;,dot,.,comma,,',
'{+keys*}' : 'semi=;,dot=.,comma=,'
},
'Fragment Expansion' : {
'{#var}' : '#value',
'{#hello}' : '#Hello%20World!',
'{#half}' : '#50%25',
'foo{#empty}' : 'foo#',
'foo{#undef}' : 'foo',
'{#x,hello,y}' : '#1024,Hello%20World!,768',
'{#path,x}/here' : '#/foo/bar,1024/here',
'{#path:6}/here' : '#/foo/b/here',
'{#list}' : '#red,green,blue',
'{#list*}' : '#red,green,blue',
'{#keys}' : '#semi,;,dot,.,comma,,',
'{#keys*}' : '#semi=;,dot=.,comma=,'
},
'Label Expansion with Dot-Prefix' : {
'{.who}' : '.fred',
'{.who,who}' : '.fred.fred',
'{.half,who}' : '.50%25.fred',
'www{.dom*}' : 'www.example.com',
'X{.var}' : 'X.value',
'X{.empty}' : 'X.',
'X{.undef}' : 'X',
'X{.var:3}' : 'X.val',
'X{.list}' : 'X.red,green,blue',
'X{.list*}' : 'X.red.green.blue',
'X{.keys}' : 'X.semi,%3B,dot,.,comma,%2C',
'X{.keys*}' : 'X.semi=%3B.dot=..comma=%2C',
'X{.empty_keys}' : 'X',
'X{.empty_keys*}' : 'X'
},
'Path Segment Expansion' : {
'{/who}' : '/fred',
'{/who,who}' : '/fred/fred',
'{/half,who}' : '/50%25/fred',
'{/who,dub}' : '/fred/me%2Ftoo',
'{/var}' : '/value',
'{/var,empty}' : '/value/',
'{/var,undef}' : '/value',
'{/var,x}/here' : '/value/1024/here',
'{/var:1,var}' : '/v/value',
'{/list}' : '/red,green,blue',
'{/list*}' : '/red/green/blue',
'{/list*,path:4}' : '/red/green/blue/%2Ffoo',
'{/keys}' : '/semi,%3B,dot,.,comma,%2C',
'{/keys*}' : '/semi=%3B/dot=./comma=%2C'
},
'Path-Style Parameter Expansion' : {
'{;who}' : ';who=fred',
'{;half}' : ';half=50%25',
'{;empty}' : ';empty',
'{;v,empty,who}' : ';v=6;empty;who=fred',
'{;v,bar,who}' : ';v=6;who=fred',
'{;x,y}' : ';x=1024;y=768',
'{;x,y,empty}' : ';x=1024;y=768;empty',
'{;x,y,undef}' : ';x=1024;y=768',
'{;hello:5}' : ';hello=Hello',
'{;list}' : ';list=red,green,blue',
'{;list*}' : ';list=red;list=green;list=blue',
'{;keys}' : ';keys=semi,%3B,dot,.,comma,%2C',
'{;keys*}' : ';semi=%3B;dot=.;comma=%2C'
},
'Form-Style Query Expansion' : {
'{?who}' : '?who=fred',
'{?half}' : '?half=50%25',
'{?x,y}' : '?x=1024&y=768',
'{?x,y,empty}' : '?x=1024&y=768&empty=',
'{?x,y,undef}' : '?x=1024&y=768',
'{?var:3}' : '?var=val',
'{?list}' : '?list=red,green,blue',
'{?list*}' : '?list=red&list=green&list=blue',
'{?keys}' : '?keys=semi,%3B,dot,.,comma,%2C',
'{?keys*}' : '?semi=%3B&dot=.&comma=%2C'
},
'Form-Style Query Continuation' : {
'{&who}' : '&who=fred',
'{&half}' : '&half=50%25',
'?fixed=yes{&x}' : '?fixed=yes&x=1024',
'{&x,y,empty}' : '&x=1024&y=768&empty=',
'{&x,y,undef}' : '&x=1024&y=768',
'{&var:3}' : '&var=val',
'{&list}' : '&list=red,green,blue',
'{&list*}' : '&list=red&list=green&list=blue',
'{&keys}' : '&keys=semi,%3B,dot,.,comma,%2C',
'{&keys*}' : '&semi=%3B&dot=.&comma=%2C'
}
},
values : {
'count' : ['one', 'two', 'three'],
'dom' : ['example', 'com'],
'dub' : 'me/too',
'hello' : 'Hello World!',
'half' : '50%',
'var' : 'value',
'who' : 'fred',
'base' : 'http://example.com/home/',
'path' : '/foo/bar',
'list' : ['red', 'green', 'blue'],
'keys' : {
'semi' : ';',
'dot' : '.',
'comma' : ','
},
'v' : '6',
'x' : '1024',
'y' : '768',
'empty' : '',
'empty_keys' : [],
'undef' : null
}
}
};
module('URITemplate');
// [].forEach() no IE, lacking interest in polyfilling this...
for (var i in levels) {
(function(level, data){
test(level, function() {
var combined_expression = '',
combined_expansion = '',
template, expression, expansion;
for (var type in data.expressions) {
for (expression in data.expressions[type]) {
combined_expression += '/' + expression;
combined_expansion += '/' + data.expressions[type][expression];
template = new URITemplate(expression);
expansion = template.expand(data.values);
equal(expansion, data.expressions[type][expression], type + ': ' + expression);
}
}
template = new URITemplate(combined_expression);
expansion = template.expand(data.values);
equal(expansion, combined_expansion, type + ': combined');
});
})(i, levels[i]);
}
test('Data Callbacks', function() {
var template = new URITemplate('{var}');
var global = function(key) {
var data = {'var': 'hello world.html'};
return data[key];
};
var local = function() {
return 'hello world.html';
};
equal(template.expand(global), 'hello%20world.html', 'global callback');
equal(template.expand({'var': local}), 'hello%20world.html', 'local callback');
});
test('Parse errors', function() {
raises(function() {
URITemplate('AB{var$}IJ').parse();
}, Error, 'Failing invalid variable name');
raises(function() {
URITemplate('AB{$var}IJ').parse();
}, Error, 'Failing invalid operator');
raises(function() {
URITemplate('AB{var:3IJ').parse();
}, Error, 'Failing missing closing }');
raises(function() {
URITemplate('AB{var:3*}IJ').parse();
}, Error, 'Failing invalid modifier');
});
test('Expansion errors', function() {
raises(function() {
var data = {'composite_var': ['multiple', 'values']};
URITemplate('{composite_var:3}').expand(data);
}, Error, 'Failing prefix modifier after composite variable');
});
test('noConflict mode', function() {
var actual_lib = URITemplate; // actual library; after loading, before noConflict()
var unconflicted = URITemplate.noConflict();
strictEqual( unconflicted, actual_lib, 'noConflict() returns the URITemplate object' );
strictEqual( URITemplate, URITemplate_pre_lib, 'noConflict() restores the `URITemplate` variable' );
// restore for other tests
window.URITemplate = actual_lib;
});
test('Periods in varnames', function() {
var template = new URITemplate('{hello.world.var}');
var literal = 'replacement';
var data = {'hello.world.var': literal};
var expansion = template.expand(data);
equal(expansion, literal, 'period in varname');
});
test('Invalid literals', function () {
raises(function() {
URITemplate('invalid.char}acter').parse();
}, Error, 'Failing invalid literal');
});
})();

1892
test/urls.js Normal file

File diff suppressed because it is too large Load Diff

234
uri-template.html Normal file
View File

@ -0,0 +1,234 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>URI.js - URI-Template</title>
<meta name="description" content="URI.js is a Javascript library for working with URLs." />
<script src="jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="prettify/prettify.js" type="text/javascript"></script>
<script src="screen.js" type="text/javascript"></script>
<link href="screen.css" rel="stylesheet" type="text/css" />
<link href="prettify/prettify.sunburst.css" rel="stylesheet" type="text/css" />
<script src="src/URI.min.js" type="text/javascript"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8922143-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<style type="text/css">
.tpl-operator {
font-weight: bold;
color: #669933;
}
.tpl-variable {
font-weight: bold;
color: #336699;
}
.tpl-modifier {
font-weight: bold;
color: #663399;
}
pre {
padding: 10px;
background: #EEE;
}
table {
width: 100%;
border: 1px solid #AAA;
border-collapse: collapse;
}
td, th {
border: 1px solid #AAA;
text-align: left;
padding: 3px;
}
th {
background: #EEE;
}
</style>
</head>
<body>
<a id="github-forkme" href="https://github.com/medialize/URI.js"><img src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div id="container">
<h1><a href="https://github.com/medialize/URI.js">URI.js</a></h1>
<ul class="menu">
<li><a href="/URI.js/">Intro</a></li>
<li><a href="about-uris.html">Understanding URIs</a></li>
<li><a href="docs.html">API-Documentation</a></li>
<li><a href="jquery-uri-plugin.html">jQuery Plugin</a></li>
<li class="active"><a href="uri-template.html">URI Template</a></li>
<li><a href="build.html">Build</a></li>
<li><a href="http://rodneyrehm.de/en/">Author</a></li>
</ul>
<h2>URI Template</h2>
<p>As of version 1.7.0 URI.js includes an implementation of URI Templates, as specified in <a href="http://tools.ietf.org/html/rfc6570">RFC 6570</a> (Level 4, March 2012).</p>
<h2>Using URI Templates</h2>
<pre class="prettyprint lang-js">
// creating a new URI Template
var template = new URITemplate("http://example.org/{file}");
var result = template.expand({file: "hello world.html"});
result === "http://example.org/hello%20world.html";
// of course you can call the constructor like a function and chain things:
result = URITemplate("http://example.org/{file}")
.expand({file: "hello world.html"});
result === "http://example.org/hello%20world.html";
// access via URI
result = URI.expand("http://example.org/{file}", {file: "hello world.html"});
// result == new URI("http://example.org/hello%20world.html");
// expand() accepts data-callbacks:
template.expand(function(key) {
var data = {file: "hello world.html"};
return data[key];
});
// expand() accepts key-callbacks:
template.expand({file : function(key) {
return "hello world.html";
}});
</pre>
<h2>URI Template Syntax</h2>
<p><em>Expressions</em> are placeholders which are to be substituted by the values their variables reference.</p>
<ul>
<li><code>http://example.org/~<strong>{<em class="tpl-variable">username</em>}</strong>/</code></li>
<li><code>http://example.org/dictionary/<strong>{<em class="tpl-variable">term</em><span class="tpl-modifier">:1</span>}</strong>/<strong>{<em class="tpl-variable">term</em>}</strong></code></li>
<li><code>http://example.org/search<strong>{<span class="tpl-operator">?</span><em class="tpl-variable">q</em><span class="tpl-modifier">*</span>,<em class="tpl-variable">lang</em>}</strong></code></li>
</ul>
<p>
An expression consists of an <span class="tpl-operator">operator</span> and a (comma-separated) list of <em>variable-specifications</em>.
A variable-specification consists of a <em class="tpl-variable">variable</em> and an optional <em class="tpl-modifier">modifier</em>.
</p>
<hr>
<p>Given the template</p>
<pre><code>http://example.org/~<strong>{<em class="tpl-variable">username</em>}</strong>/<strong>{<em class="tpl-variable">term</em><span class="tpl-modifier">:1</span>}</strong>/<strong>{<em class="tpl-variable">term</em>}</strong><strong>{<span class="tpl-operator">?</span><em class="tpl-variable">q</em><span class="tpl-modifier">*</span>,<em class="tpl-variable">lang</em>}</strong></code></pre>
<p>and the following data: </p>
<pre><code>{username: "rodneyrehm", term: "hello world", q: {a: "mars", b: "jupiter"}, lang: "en"}</code></pre>
<p>the expansion looks as follows:
<pre><code>"http://example.org/~rodneyrehm/h/hello%20world?a=mars&amp;b=jupiter&amp;lang=en"</code></pre>
<hr>
<p>List of supported <span class="tpl-operator">operators</span>:</p>
<table>
<tr><th>Operator</th><th>Description</th></tr>
<tr><td><code><em>None</em></code></td><td>Simple String Expansion;</td></tr>
<tr><td><code>+</code></td><td>Reserved character strings;</td></tr>
<tr><td><code>#</code></td><td>Fragment identifiers prefixed by "#";</td></tr>
<tr><td><code>.</code></td><td>Name labels or extensions prefixed by ".";</td></tr>
<tr><td><code>/</code></td><td>Path segments prefixed by "/";</td></tr>
<tr><td><code>;</code></td><td>Path parameter name or name=value pairs prefixed by ";";</td></tr>
<tr><td><code>?</code></td><td>Query component beginning with "?" and consisting of name=value pairs separated by "&amp;"; and,</td></tr>
<tr><td><code>&amp;</code></td><td>Continuation of query-style &amp;name=value pairs within a literal query component.</td></tr>
</table>
<p>List of supported <span class="tpl-modifier">modifiers</span>:</p>
<table>
<tr><th>Modifier</th><th>Description</th></tr>
<tr><td><code><em>None</em></code></td><td>No modification, arrays and objects are joined with ","</td></tr>
<tr><td><code>*</code></td><td>Explode arrays and objects (see tables below)</td></tr>
<tr><td><code>:3</code></td><td>Substring of the first 3 characters of the variable's value</td></tr>
</table>
<h3>Strings and Numbers</h3>
<p>
Given <code>{"var": "hello[world]"}</code>, the expression <code>{var}</code> expands to <code>hello%5Bworld%5D</code>.
The following table shows an output matrix for every possible operator/modifier combination produced for <code>string</code> input.
</p>
<table>
<tr><th></th><th colspan="3">Modifier</th></tr>
<tr><th>Operator</th><th><em>None</em></th><th>*</th><th>:2</th></tr>
<tr><td><code><em>None</em></code></td><td><code>hello%5Bworld%5D</code></td><td><code>hello%5Bworld%5D</code></td><td><code>he</code></td></tr>
<tr><td><code><em>+</em></code></td><td><code>hello[world]</code></td><td><code>hello[world]</code></td><td><code>he</code></td></tr>
<tr><td><code>#</code></td><td><code>#hello[world]</code></td><td><code>#hello[world]</code></td><td><code>#he</code></td></tr>
<tr><td><code>.</code></td><td><code>.hello%5Bworld%5D</code></td><td><code>.hello%5Bworld%5D</code></td><td><code>.he</code></td></tr>
<tr><td><code>/</code></td><td><code>/hello%5Bworld%5D</code></td><td><code>/hello%5Bworld%5D</code></td><td><code>/he</code></td></tr>
<tr><td><code>;</code></td><td><code>;var=hello%5Bworld%5D</code></td><td><code>;var=hello%5Bworld%5D</code></td><td><code>;var=he</code></td></tr>
<tr><td><code>?</code></td><td><code>?var=hello%5Bworld%5D</code></td><td><code>?var=hello%5Bworld%5D</code></td><td><code>?var=he</code></td></tr>
<tr><td><code>&amp;</code></td><td><code>&amp;var=hello%5Bworld%5D</code></td><td><code>&amp;var=hello%5Bworld%5D</code></td><td><code>&amp;var=he</code></td></tr>
</table>
<h3>Arrays</h3>
<p>
Given <code>{"var": ["one", "two", "three"]}</code>, the expression <code>{var}</code> expands to <code>one,two,three</code>.
The following table shows an output matrix for every possible operator/modifier combination produced for <code>array</code> input.
</p>
<table>
<tr><th></th><th colspan="3">Modifier</th></tr>
<tr><th>Operator</th><th><em>None</em></th><th>*</th><th>:2</th></tr>
<tr><td><code><em>None</em></code></td><td><code>one,two,three</code></td><td><code>one,two,three</code></td><td><code>on,tw,th</code></td></tr>
<tr><td><code><em>+</em></code></td><td><code>one,two,three</code></td><td><code>one,two,three</code></td><td><code>on,tw,th</code></td></tr>
<tr><td><code>#</code></td><td><code>#one,two,three</code></td><td><code>#one,two,three</code></td><td><code>#on,tw,th</code></td></tr>
<tr><td><code>.</code></td><td><code>.one,two,three</code></td><td><code>.one.two.three</code></td><td><code>.on,tw,th</code></td></tr>
<tr><td><code>/</code></td><td><code>/one,two,three</code></td><td><code>/one/two/three</code></td><td><code>/on,tw,th</code></td></tr>
<tr><td><code>;</code></td><td><code>;var=one,two,three</code></td><td><code>;var=one;var=two;var=three</code></td><td><code>;var=on,tw,th</code></td></tr>
<tr><td><code>?</code></td><td><code>?var=one,two,three</code></td><td><code>?var=one&amp;var=two&amp;var=three</code></td><td><code>?var=on,tw,th</code></td></tr>
<tr><td><code>&amp;</code></td><td><code>&amp;var=one,two,three</code></td><td><code>&amp;var=one&amp;var=two&amp;var=three</code></td><td><code>&amp;var=on,tw,th</code></td></tr>
</table>
<h3>Objects ("plain objects" / "hash maps")</h3>
<p>
Given <code>{"var": {"one": "alpha", "two": "bravo"}}</code>, the expression <code>{var}</code> expands to <code>one,two,three</code>.
The following table shows an output matrix for every possible operator/modifier combination produced for <code>object</code> input.
</p>
<table>
<tr><th></th><th colspan="3">Modifier</th></tr>
<tr><th>Operator</th><th><em>None</em></th><th>*</th><th>:2</th></tr>
<tr><td><code><em>None</em></code></td><td><code>one,alpha,two,bravo</code></td><td><code>one=alpha,two=bravo</code></td><td><code>on,al,tw,br</code></td></tr>
<tr><td><code><em>+</em></code></td><td><code>one,alpha,two,bravo</code></td><td><code>one=alpha,two=bravo</code></td><td><code>on,al,tw,br</code></td></tr>
<tr><td><code>#</code></td><td><code>#one,alpha,two,bravo</code></td><td><code>#one=alpha,two=bravo</code></td><td><code>#on,al,tw,br</code></td></tr>
<tr><td><code>.</code></td><td><code>.one,alpha,two,bravo</code></td><td><code>.one=alpha.two=bravo</code></td><td><code>.on,al,tw,br</code></td></tr>
<tr><td><code>/</code></td><td><code>/one,alpha,two,bravo</code></td><td><code>/one=alpha/two=bravo</code></td><td><code>/on,al,tw,br</code></td></tr>
<tr><td><code>;</code></td><td><code>;var=one,alpha,two,bravo</code></td><td><code>;one=alpha;two=bravo</code></td><td><code>;var=on,al,tw,br</code></td></tr>
<tr><td><code>?</code></td><td><code>?var=one,alpha,two,bravo</code></td><td><code>?one=alpha&amp;two=bravo</code></td><td><code>?var=on,al,tw,br</code></td></tr>
<tr><td><code>&amp;</code></td><td><code>&amp;var=one,alpha,two,bravo</code></td><td><code>&amp;one=alpha&amp;two=bravo</code></td><td><code>&amp;var=on,al,tw,br</code></td></tr>
</table>
<h2>Limitations</h2>
<p>URI Template is a <em>Proposed Standard</em> and because of that I did not want to deviate from it. That said I'm not at all happy with how the specification turned out. Here are some of my thoughts:</p>
<ul>
<li>The <em>explode modifier</em> works the wrong way. <code>{?some_object}</code> should lead to <code>?foo=bar&amp;hello=world</code>, as this is the common expansion</li>
<li>The <em>prefix modifier</em> (which I would've named <em>truncate modifier</em>) only has an end-offset.
The specification says it's »used to partition an identifier space hierarchically«. <code>abc</code> may become <code>a/bc</code> or <code>a/ab/abc</code>.
But there is no way of modifying output to <code>a/b/c</code> or <code>a/b/abc</code>. Whenever I had to partition identifier spaces, I used one of the latter patterns.</li>
<li>Operators like <code>.</code> automatically prefix the expansion. So <code>{"var": ["filename", "extension"]}</code> and <code>{.var*}</code> results in <code>.filename.extension</code> - obviously not what I wanted.</li>
<li>Variable names (<em>varname</em>) may only contain <code>ALPHA / DIGIT / "_" / pct-encoded</code> and may not be decoded for resolving the reference. This simply feels weird, especially the "may not be decoded" part.</li>
<li>Other possible modifiers could include some simple character-munging like <em>UPPERCASE</em>, <em>LOWERCASE</em>, <em>CAPITALCASE</em></li>
<li><code>{/var,empty,empty}</code> results in <code>/foobar//</code> - clearly not what one intended</li>
<li><code>{var}</code> and <code>{"var" : {"a": "1", "b": "2"}}</code> results in <code>a,1,b,2</code> - excusemewhat? I would've expected <code>a=1,b=2</code> or <code>a:1,b:2</code> (in a perverse parallel universe).</li>
<li>Spaces in the <em>query string</em> should be encoded to <code>+</code>, not <code>%20</code> according to <a href="http://www.w3.org/TR/html401/interact/forms.html#form-content-type">application/x-www-form-urlencoded</a></li>
</ul>
</div>
</body>
</html>

37
utils/SLDs.php Normal file
View File

@ -0,0 +1,37 @@
<?php
$map = array();
// grab list of known SLDs from https://github.com/gavingmiller/second-level-domains
// using curl since file_get_contents() won't do SSL...
$url = 'https://raw.github.com/gavingmiller/second-level-domains/master/SLDs.csv';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
$source = curl_exec($curl);
// $source is a CSV, but a rather simple one I wouldn't go through the hassle of using str_getcsv() for
$source = preg_split("/\r\n|\r|\n/", $source);
foreach ($source as $line) {
$t = explode(',', $line);
$tld = strtolower(substr($t[0], 1)); // skip the leading dot
$sld = strtolower(substr($t[1], 1, strrpos($t[1], '.') - 1));
if (!$tld || !$sld || strpos($sld, '.') !== false) {
continue;
}
$map[$tld][] = $sld;
}
// source seems to be tainted with duplicates (and false SLDs like "govt.uk")
// for now we don't care about false (or missing) SLDs
foreach ($map as $tld => &$slds) {
$slds = array_unique($slds);
sort($slds);
$slds = join('|', $slds);
}
echo json_encode($map);

101
utils/sld.js Normal file
View File

@ -0,0 +1,101 @@
var fs = require('fs');
var url = require('url');
var http = require('http');
var domains = {};
/*
Problem with PublicSuffix:
The list not only contains TLDs/SLDs, but also domains like "dyndns.org".
While this may be useful for Cookie-Origin-Policy, these domains are possibly
being handled by URI.js, considering URI("//dyndns.org").tld("com").
The list does not distinguish "official" TLDs from such domains.
(At least I have problems with treating "cc.ga.us" as a SLD)
*/
http.get("http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1", function(res) {
res.on('data', function(data) {
data.toString().replace(/\r/g, "").split("\n").forEach(function(line) {
// skip empty lines, comments and TLDs
if (!line || (line[0] === "/" && line[1] === "/") || line.indexOf('.') === -1) {
return;
}
var parts = line.split('.');
var sld = parts.slice(0, -1).join('.');
var tld = parts.slice(-1);
if (parts.length < 2) {
return;
}
if (!domains[tld]) {
domains[tld] = [];
}
domains[tld].push(sld);
});
}).on('end', function() {
//file.end();
for (var tld in domains) {
domains[tld].sort();
// ! and * are sorted to the top
if (domains[tld][0][0] == '!') {
// we have wildcards and exclusions
} else if (domains[tld][0][0] == '*') {
// we have wildcards
} else {
// simple list
}
}
console.log(JSON.stringify(domains, null, 2));
//console.log(domains.jp);
});
});
/*
// https://github.com/oncletom/tld.js
// generates a 430KB file, which is inacceptible for the web
build a regex pattern from this -- http://publicsuffix.org/list/
"!exclusion"
"*" wildcard
uk: [ '!bl',
'!british-library',
'!jet',
'!mod',
'!national-library-scotland',
'!nel',
'!nic',
'!nls',
'!parliament',
'*',
'*.nhs',
'*.police',
'*.sch',
'blogspot.co' ]
jp: [ '!city.kawasaki',
'!city.kitakyushu',
'!city.kobe',
'!city.nagoya',
'!city.sapporo',
'!city.sendai',
'!city.yokohama',
'*.kawasaki',
'*.kitakyushu',
'*.kobe',
'*.nagoya',
'*.sapporo',
'*.sendai',
'*.yokohama',
'abashiri.hokkaido',
'abeno.osaka',
'abiko.chiba',
]
*/