epuber 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/bin/epuber +10 -0
- data/epuber.gemspec +51 -0
- data/lib/epuber.rb +14 -0
- data/lib/epuber/book.rb +267 -0
- data/lib/epuber/book/contributor.rb +90 -0
- data/lib/epuber/book/file_request.rb +68 -0
- data/lib/epuber/book/target.rb +284 -0
- data/lib/epuber/book/toc_item.rb +130 -0
- data/lib/epuber/checker.rb +19 -0
- data/lib/epuber/checker/text_checker.rb +129 -0
- data/lib/epuber/checker_transformer_base.rb +71 -0
- data/lib/epuber/command.rb +65 -0
- data/lib/epuber/command/compile.rb +142 -0
- data/lib/epuber/command/init.rb +145 -0
- data/lib/epuber/command/server.rb +59 -0
- data/lib/epuber/compiler.rb +255 -0
- data/lib/epuber/compiler/compilation_context.rb +86 -0
- data/lib/epuber/compiler/file_finders/abstract.rb +270 -0
- data/lib/epuber/compiler/file_finders/imaginary.rb +167 -0
- data/lib/epuber/compiler/file_finders/normal.rb +22 -0
- data/lib/epuber/compiler/file_resolver.rb +316 -0
- data/lib/epuber/compiler/file_types/abstract_file.rb +119 -0
- data/lib/epuber/compiler/file_types/bade_file.rb +39 -0
- data/lib/epuber/compiler/file_types/container_xml_file.rb +26 -0
- data/lib/epuber/compiler/file_types/generated_file.rb +29 -0
- data/lib/epuber/compiler/file_types/ibooks_display_options_file.rb +31 -0
- data/lib/epuber/compiler/file_types/image_file.rb +42 -0
- data/lib/epuber/compiler/file_types/mime_type_file.rb +20 -0
- data/lib/epuber/compiler/file_types/nav_file.rb +42 -0
- data/lib/epuber/compiler/file_types/opf_file.rb +27 -0
- data/lib/epuber/compiler/file_types/source_file.rb +52 -0
- data/lib/epuber/compiler/file_types/static_file.rb +18 -0
- data/lib/epuber/compiler/file_types/stylus_file.rb +20 -0
- data/lib/epuber/compiler/file_types/xhtml_file.rb +102 -0
- data/lib/epuber/compiler/generator.rb +67 -0
- data/lib/epuber/compiler/meta_inf_generator.rb +41 -0
- data/lib/epuber/compiler/nav_generator.rb +201 -0
- data/lib/epuber/compiler/opf_generator.rb +284 -0
- data/lib/epuber/compiler/xhtml_processor.rb +254 -0
- data/lib/epuber/config.rb +133 -0
- data/lib/epuber/dsl/attribute.rb +248 -0
- data/lib/epuber/dsl/attribute_support.rb +130 -0
- data/lib/epuber/dsl/object.rb +145 -0
- data/lib/epuber/dsl/tree_object.rb +101 -0
- data/lib/epuber/helper.rb +19 -0
- data/lib/epuber/lockfile.rb +55 -0
- data/lib/epuber/plugin.rb +108 -0
- data/lib/epuber/ruby_extensions/match_data.rb +40 -0
- data/lib/epuber/ruby_extensions/thread.rb +13 -0
- data/lib/epuber/server.rb +614 -0
- data/lib/epuber/server/auto_refresh/auto_refresh.coffee +97 -0
- data/lib/epuber/server/auto_refresh/connector.coffee +125 -0
- data/lib/epuber/server/auto_refresh/protocol.coffee +41 -0
- data/lib/epuber/server/auto_refresh/reloader.coffee +261 -0
- data/lib/epuber/server/base.styl +3 -0
- data/lib/epuber/server/basic.styl +211 -0
- data/lib/epuber/server/book_content.styl +39 -0
- data/lib/epuber/server/default_cover.png +0 -0
- data/lib/epuber/server/fonts/AvenirNext/AvenirNext-Bold.ttf +0 -0
- data/lib/epuber/server/fonts/AvenirNext/AvenirNext-BoldItalic.ttf +0 -0
- data/lib/epuber/server/fonts/AvenirNext/AvenirNext-Italic.ttf +0 -0
- data/lib/epuber/server/fonts/AvenirNext/AvenirNext-Regular.ttf +0 -0
- data/lib/epuber/server/handlers.rb +67 -0
- data/lib/epuber/server/keyboard_control.coffee +6 -0
- data/lib/epuber/server/pages/book.bade +75 -0
- data/lib/epuber/server/pages/common.bade +59 -0
- data/lib/epuber/server/pages/files.bade +17 -0
- data/lib/epuber/server/pages/toc.bade +29 -0
- data/lib/epuber/server/support.coffee +10 -0
- data/lib/epuber/templates/template.bookspec +143 -0
- data/lib/epuber/third_party/bower.rb +22 -0
- data/lib/epuber/third_party/bower/bower.json +10 -0
- data/lib/epuber/third_party/bower/bower_components/cookies-js/bower.json +10 -0
- data/lib/epuber/third_party/bower/bower_components/cookies-js/dist/cookies.d.ts +33 -0
- data/lib/epuber/third_party/bower/bower_components/cookies-js/dist/cookies.js +173 -0
- data/lib/epuber/third_party/bower/bower_components/cookies-js/dist/cookies.min.js +6 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/MIT-LICENSE.txt +21 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/bower.json +28 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/dist/jquery.js +9210 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/dist/jquery.min.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/dist/jquery.min.map +1 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax.js +786 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/jsonp.js +89 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js +75 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/parseJSON.js +13 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/parseXML.js +28 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/script.js +64 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/var/nonce.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/var/rquery.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/xhr.js +136 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes.js +11 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/attr.js +141 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/classes.js +158 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/prop.js +94 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/support.js +35 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/val.js +161 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/callbacks.js +205 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core.js +502 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/access.js +60 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/init.js +123 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/parseHTML.js +39 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/ready.js +97 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/var/rsingleTag.js +4 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css.js +450 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/addGetHookIf.js +22 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/curCSS.js +57 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/defaultDisplay.js +70 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/hiddenVisibleSelectors.js +15 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/support.js +96 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/swap.js +28 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/cssExpand.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/getStyles.js +12 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/isHidden.js +13 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/rmargin.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/rnumnonpx.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data.js +178 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/Data.js +181 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/accepts.js +20 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/var/data_priv.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/var/data_user.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/deferred.js +149 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/deprecated.js +13 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/dimensions.js +50 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/effects.js +648 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/effects/Tween.js +114 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/effects/animatedSelector.js +13 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event.js +868 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/ajax.js +13 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/alias.js +39 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/support.js +9 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/exports/amd.js +24 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/exports/global.js +32 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/intro.js +44 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/jquery.js +37 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation.js +580 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/_evalUrl.js +18 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/support.js +32 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/var/rcheckableType.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/offset.js +207 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/outro.js +1 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/queue.js +142 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/queue/delay.js +22 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/selector-native.js +172 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/selector-sizzle.js +14 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/selector.js +1 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/serialize.js +111 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/sizzle/dist/sizzle.js +2067 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/sizzle/dist/sizzle.min.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/sizzle/dist/sizzle.min.map +1 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing.js +199 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing/findFilter.js +100 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing/var/rneedsContext.js +6 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/arr.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/class2type.js +4 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/concat.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/hasOwn.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/indexOf.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/pnum.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/push.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/rnotwhite.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/slice.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/strundefined.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/support.js +4 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/toString.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/wrap.js +79 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/MIT-LICENSE +20 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/Makefile +4 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/README.markdown +212 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/bower.json +27 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/keymaster.js +296 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/package.json +11 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/test.html +93 -0
- data/lib/epuber/third_party/bower/bower_components/spin.js/LICENSE.txt +21 -0
- data/lib/epuber/third_party/bower/bower_components/spin.js/README.md +21 -0
- data/lib/epuber/third_party/bower/bower_components/spin.js/bower.json +18 -0
- data/lib/epuber/third_party/bower/bower_components/spin.js/jquery.spin.js +80 -0
- data/lib/epuber/third_party/bower/bower_components/spin.js/spin.js +337 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/LICENSE.txt +21 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/README.md +534 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/bower.json +16 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/contributing.md +19 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/IPv6.js +188 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/SecondLevelDomains.js +241 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.fragmentQuery.js +104 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.fragmentURI.js +97 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.js +2115 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.min.js +86 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URITemplate.js +499 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/jquery.URI.js +235 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/jquery.URI.min.js +7 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/punycode.js +508 -0
- data/lib/epuber/transformer.rb +19 -0
- data/lib/epuber/transformer/text_transformer.rb +60 -0
- data/lib/epuber/user_interface.rb +186 -0
- data/lib/epuber/vendor/globals_context.rb +26 -0
- data/lib/epuber/vendor/hash_binding.rb +26 -0
- data/lib/epuber/vendor/nokogiri_extensions.rb +30 -0
- data/lib/epuber/vendor/ruby_templater.rb +71 -0
- data/lib/epuber/vendor/size.rb +20 -0
- data/lib/epuber/vendor/version.rb +83 -0
- data/lib/epuber/version.rb +4 -0
- metadata +556 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
# Contributing to URI.js #
|
2
|
+
|
3
|
+
URI.js Project License: MIT License
|
4
|
+
|
5
|
+
* You will only Submit Contributions where You have authored 100% of the content.
|
6
|
+
* 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.
|
7
|
+
* Whatever content You Contribute will be provided under the project License.
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
Thanks for your help!
|
12
|
+
|
13
|
+
Pull Requests go into the branch **master**. The *gh-pages* branch is a presentation of the *master* branch at the last given release.
|
14
|
+
|
15
|
+
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.
|
16
|
+
|
17
|
+
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!
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,188 @@
|
|
1
|
+
/*!
|
2
|
+
* URI.js - Mutating URLs
|
3
|
+
* IPv6 Support
|
4
|
+
*
|
5
|
+
* Version: 1.15.2
|
6
|
+
*
|
7
|
+
* Author: Rodney Rehm
|
8
|
+
* Web: http://medialize.github.io/URI.js/
|
9
|
+
*
|
10
|
+
* Licensed under
|
11
|
+
* MIT License http://www.opensource.org/licenses/mit-license
|
12
|
+
* GPL v3 http://opensource.org/licenses/GPL-3.0
|
13
|
+
*
|
14
|
+
*/
|
15
|
+
|
16
|
+
(function (root, factory) {
|
17
|
+
'use strict';
|
18
|
+
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
19
|
+
if (typeof exports === 'object') {
|
20
|
+
// Node
|
21
|
+
module.exports = factory();
|
22
|
+
} else if (typeof define === 'function' && define.amd) {
|
23
|
+
// AMD. Register as an anonymous module.
|
24
|
+
define(factory);
|
25
|
+
} else {
|
26
|
+
// Browser globals (root is window)
|
27
|
+
root.IPv6 = factory(root);
|
28
|
+
}
|
29
|
+
}(this, function (root) {
|
30
|
+
'use strict';
|
31
|
+
|
32
|
+
/*
|
33
|
+
var _in = "fe80:0000:0000:0000:0204:61ff:fe9d:f156";
|
34
|
+
var _out = IPv6.best(_in);
|
35
|
+
var _expected = "fe80::204:61ff:fe9d:f156";
|
36
|
+
|
37
|
+
console.log(_in, _out, _expected, _out === _expected);
|
38
|
+
*/
|
39
|
+
|
40
|
+
// save current IPv6 variable, if any
|
41
|
+
var _IPv6 = root && root.IPv6;
|
42
|
+
|
43
|
+
function bestPresentation(address) {
|
44
|
+
// based on:
|
45
|
+
// Javascript to test an IPv6 address for proper format, and to
|
46
|
+
// present the "best text representation" according to IETF Draft RFC at
|
47
|
+
// http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04
|
48
|
+
// 8 Feb 2010 Rich Brown, Dartware, LLC
|
49
|
+
// Please feel free to use this code as long as you provide a link to
|
50
|
+
// http://www.intermapper.com
|
51
|
+
// http://intermapper.com/support/tools/IPV6-Validator.aspx
|
52
|
+
// http://download.dartware.com/thirdparty/ipv6validator.js
|
53
|
+
|
54
|
+
var _address = address.toLowerCase();
|
55
|
+
var segments = _address.split(':');
|
56
|
+
var length = segments.length;
|
57
|
+
var total = 8;
|
58
|
+
|
59
|
+
// trim colons (:: or ::a:b:c… or …a:b:c::)
|
60
|
+
if (segments[0] === '' && segments[1] === '' && segments[2] === '') {
|
61
|
+
// must have been ::
|
62
|
+
// remove first two items
|
63
|
+
segments.shift();
|
64
|
+
segments.shift();
|
65
|
+
} else if (segments[0] === '' && segments[1] === '') {
|
66
|
+
// must have been ::xxxx
|
67
|
+
// remove the first item
|
68
|
+
segments.shift();
|
69
|
+
} else if (segments[length - 1] === '' && segments[length - 2] === '') {
|
70
|
+
// must have been xxxx::
|
71
|
+
segments.pop();
|
72
|
+
}
|
73
|
+
|
74
|
+
length = segments.length;
|
75
|
+
|
76
|
+
// adjust total segments for IPv4 trailer
|
77
|
+
if (segments[length - 1].indexOf('.') !== -1) {
|
78
|
+
// found a "." which means IPv4
|
79
|
+
total = 7;
|
80
|
+
}
|
81
|
+
|
82
|
+
// fill empty segments them with "0000"
|
83
|
+
var pos;
|
84
|
+
for (pos = 0; pos < length; pos++) {
|
85
|
+
if (segments[pos] === '') {
|
86
|
+
break;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
if (pos < total) {
|
91
|
+
segments.splice(pos, 1, '0000');
|
92
|
+
while (segments.length < total) {
|
93
|
+
segments.splice(pos, 0, '0000');
|
94
|
+
}
|
95
|
+
|
96
|
+
length = segments.length;
|
97
|
+
}
|
98
|
+
|
99
|
+
// strip leading zeros
|
100
|
+
var _segments;
|
101
|
+
for (var i = 0; i < total; i++) {
|
102
|
+
_segments = segments[i].split('');
|
103
|
+
for (var j = 0; j < 3 ; j++) {
|
104
|
+
if (_segments[0] === '0' && _segments.length > 1) {
|
105
|
+
_segments.splice(0,1);
|
106
|
+
} else {
|
107
|
+
break;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
segments[i] = _segments.join('');
|
112
|
+
}
|
113
|
+
|
114
|
+
// find longest sequence of zeroes and coalesce them into one segment
|
115
|
+
var best = -1;
|
116
|
+
var _best = 0;
|
117
|
+
var _current = 0;
|
118
|
+
var current = -1;
|
119
|
+
var inzeroes = false;
|
120
|
+
// i; already declared
|
121
|
+
|
122
|
+
for (i = 0; i < total; i++) {
|
123
|
+
if (inzeroes) {
|
124
|
+
if (segments[i] === '0') {
|
125
|
+
_current += 1;
|
126
|
+
} else {
|
127
|
+
inzeroes = false;
|
128
|
+
if (_current > _best) {
|
129
|
+
best = current;
|
130
|
+
_best = _current;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
} else {
|
134
|
+
if (segments[i] === '0') {
|
135
|
+
inzeroes = true;
|
136
|
+
current = i;
|
137
|
+
_current = 1;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
if (_current > _best) {
|
143
|
+
best = current;
|
144
|
+
_best = _current;
|
145
|
+
}
|
146
|
+
|
147
|
+
if (_best > 1) {
|
148
|
+
segments.splice(best, _best, '');
|
149
|
+
}
|
150
|
+
|
151
|
+
length = segments.length;
|
152
|
+
|
153
|
+
// assemble remaining segments
|
154
|
+
var result = '';
|
155
|
+
if (segments[0] === '') {
|
156
|
+
result = ':';
|
157
|
+
}
|
158
|
+
|
159
|
+
for (i = 0; i < length; i++) {
|
160
|
+
result += segments[i];
|
161
|
+
if (i === length - 1) {
|
162
|
+
break;
|
163
|
+
}
|
164
|
+
|
165
|
+
result += ':';
|
166
|
+
}
|
167
|
+
|
168
|
+
if (segments[length - 1] === '') {
|
169
|
+
result += ':';
|
170
|
+
}
|
171
|
+
|
172
|
+
return result;
|
173
|
+
}
|
174
|
+
|
175
|
+
function noConflict() {
|
176
|
+
/*jshint validthis: true */
|
177
|
+
if (root.IPv6 === this) {
|
178
|
+
root.IPv6 = _IPv6;
|
179
|
+
}
|
180
|
+
|
181
|
+
return this;
|
182
|
+
}
|
183
|
+
|
184
|
+
return {
|
185
|
+
best: bestPresentation,
|
186
|
+
noConflict: noConflict
|
187
|
+
};
|
188
|
+
}));
|
@@ -0,0 +1,241 @@
|
|
1
|
+
/*!
|
2
|
+
* URI.js - Mutating URLs
|
3
|
+
* Second Level Domain (SLD) Support
|
4
|
+
*
|
5
|
+
* Version: 1.15.2
|
6
|
+
*
|
7
|
+
* Author: Rodney Rehm
|
8
|
+
* Web: http://medialize.github.io/URI.js/
|
9
|
+
*
|
10
|
+
* Licensed under
|
11
|
+
* MIT License http://www.opensource.org/licenses/mit-license
|
12
|
+
* GPL v3 http://opensource.org/licenses/GPL-3.0
|
13
|
+
*
|
14
|
+
*/
|
15
|
+
|
16
|
+
(function (root, factory) {
|
17
|
+
'use strict';
|
18
|
+
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
19
|
+
if (typeof exports === 'object') {
|
20
|
+
// Node
|
21
|
+
module.exports = factory();
|
22
|
+
} else if (typeof define === 'function' && define.amd) {
|
23
|
+
// AMD. Register as an anonymous module.
|
24
|
+
define(factory);
|
25
|
+
} else {
|
26
|
+
// Browser globals (root is window)
|
27
|
+
root.SecondLevelDomains = factory(root);
|
28
|
+
}
|
29
|
+
}(this, function (root) {
|
30
|
+
'use strict';
|
31
|
+
|
32
|
+
// save current SecondLevelDomains variable, if any
|
33
|
+
var _SecondLevelDomains = root && root.SecondLevelDomains;
|
34
|
+
|
35
|
+
var SLD = {
|
36
|
+
// list of known Second Level Domains
|
37
|
+
// converted list of SLDs from https://github.com/gavingmiller/second-level-domains
|
38
|
+
// ----
|
39
|
+
// publicsuffix.org is more current and actually used by a couple of browsers internally.
|
40
|
+
// downside is it also contains domains like "dyndns.org" - which is fine for the security
|
41
|
+
// issues browser have to deal with (SOP for cookies, etc) - but is way overboard for URI.js
|
42
|
+
// ----
|
43
|
+
list: {
|
44
|
+
'ac':' com gov mil net org ',
|
45
|
+
'ae':' ac co gov mil name net org pro sch ',
|
46
|
+
'af':' com edu gov net org ',
|
47
|
+
'al':' com edu gov mil net org ',
|
48
|
+
'ao':' co ed gv it og pb ',
|
49
|
+
'ar':' com edu gob gov int mil net org tur ',
|
50
|
+
'at':' ac co gv or ',
|
51
|
+
'au':' asn com csiro edu gov id net org ',
|
52
|
+
'ba':' co com edu gov mil net org rs unbi unmo unsa untz unze ',
|
53
|
+
'bb':' biz co com edu gov info net org store tv ',
|
54
|
+
'bh':' biz cc com edu gov info net org ',
|
55
|
+
'bn':' com edu gov net org ',
|
56
|
+
'bo':' com edu gob gov int mil net org tv ',
|
57
|
+
'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 ',
|
58
|
+
'bs':' com edu gov net org ',
|
59
|
+
'bz':' du et om ov rg ',
|
60
|
+
'ca':' ab bc mb nb nf nl ns nt nu on pe qc sk yk ',
|
61
|
+
'ck':' biz co edu gen gov info net org ',
|
62
|
+
'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 ',
|
63
|
+
'co':' com edu gov mil net nom org ',
|
64
|
+
'cr':' ac c co ed fi go or sa ',
|
65
|
+
'cy':' ac biz com ekloges gov ltd name net org parliament press pro tm ',
|
66
|
+
'do':' art com edu gob gov mil net org sld web ',
|
67
|
+
'dz':' art asso com edu gov net org pol ',
|
68
|
+
'ec':' com edu fin gov info med mil net org pro ',
|
69
|
+
'eg':' com edu eun gov mil name net org sci ',
|
70
|
+
'er':' com edu gov ind mil net org rochest w ',
|
71
|
+
'es':' com edu gob nom org ',
|
72
|
+
'et':' biz com edu gov info name net org ',
|
73
|
+
'fj':' ac biz com info mil name net org pro ',
|
74
|
+
'fk':' ac co gov net nom org ',
|
75
|
+
'fr':' asso com f gouv nom prd presse tm ',
|
76
|
+
'gg':' co net org ',
|
77
|
+
'gh':' com edu gov mil org ',
|
78
|
+
'gn':' ac com gov net org ',
|
79
|
+
'gr':' com edu gov mil net org ',
|
80
|
+
'gt':' com edu gob ind mil net org ',
|
81
|
+
'gu':' com edu gov net org ',
|
82
|
+
'hk':' com edu gov idv net org ',
|
83
|
+
'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 ',
|
84
|
+
'id':' ac co go mil net or sch web ',
|
85
|
+
'il':' ac co gov idf k12 muni net org ',
|
86
|
+
'in':' ac co edu ernet firm gen gov i ind mil net nic org res ',
|
87
|
+
'iq':' com edu gov i mil net org ',
|
88
|
+
'ir':' ac co dnssec gov i id net org sch ',
|
89
|
+
'it':' edu gov ',
|
90
|
+
'je':' co net org ',
|
91
|
+
'jo':' com edu gov mil name net org sch ',
|
92
|
+
'jp':' ac ad co ed go gr lg ne or ',
|
93
|
+
'ke':' ac co go info me mobi ne or sc ',
|
94
|
+
'kh':' com edu gov mil net org per ',
|
95
|
+
'ki':' biz com de edu gov info mob net org tel ',
|
96
|
+
'km':' asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ',
|
97
|
+
'kn':' edu gov net org ',
|
98
|
+
'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 ',
|
99
|
+
'kw':' com edu gov net org ',
|
100
|
+
'ky':' com edu gov net org ',
|
101
|
+
'kz':' com edu gov mil net org ',
|
102
|
+
'lb':' com edu gov net org ',
|
103
|
+
'lk':' assn com edu gov grp hotel int ltd net ngo org sch soc web ',
|
104
|
+
'lr':' com edu gov net org ',
|
105
|
+
'lv':' asn com conf edu gov id mil net org ',
|
106
|
+
'ly':' com edu gov id med net org plc sch ',
|
107
|
+
'ma':' ac co gov m net org press ',
|
108
|
+
'mc':' asso tm ',
|
109
|
+
'me':' ac co edu gov its net org priv ',
|
110
|
+
'mg':' com edu gov mil nom org prd tm ',
|
111
|
+
'mk':' com edu gov inf name net org pro ',
|
112
|
+
'ml':' com edu gov net org presse ',
|
113
|
+
'mn':' edu gov org ',
|
114
|
+
'mo':' com edu gov net org ',
|
115
|
+
'mt':' com edu gov net org ',
|
116
|
+
'mv':' aero biz com coop edu gov info int mil museum name net org pro ',
|
117
|
+
'mw':' ac co com coop edu gov int museum net org ',
|
118
|
+
'mx':' com edu gob net org ',
|
119
|
+
'my':' com edu gov mil name net org sch ',
|
120
|
+
'nf':' arts com firm info net other per rec store web ',
|
121
|
+
'ng':' biz com edu gov mil mobi name net org sch ',
|
122
|
+
'ni':' ac co com edu gob mil net nom org ',
|
123
|
+
'np':' com edu gov mil net org ',
|
124
|
+
'nr':' biz com edu gov info net org ',
|
125
|
+
'om':' ac biz co com edu gov med mil museum net org pro sch ',
|
126
|
+
'pe':' com edu gob mil net nom org sld ',
|
127
|
+
'ph':' com edu gov i mil net ngo org ',
|
128
|
+
'pk':' biz com edu fam gob gok gon gop gos gov net org web ',
|
129
|
+
'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 ',
|
130
|
+
'pr':' ac biz com edu est gov info isla name net org pro prof ',
|
131
|
+
'ps':' com edu gov net org plo sec ',
|
132
|
+
'pw':' belau co ed go ne or ',
|
133
|
+
'ro':' arts com firm info nom nt org rec store tm www ',
|
134
|
+
'rs':' ac co edu gov in org ',
|
135
|
+
'sb':' com edu gov net org ',
|
136
|
+
'sc':' com edu gov net org ',
|
137
|
+
'sh':' co com edu gov net nom org ',
|
138
|
+
'sl':' com edu gov net org ',
|
139
|
+
'st':' co com consulado edu embaixada gov mil net org principe saotome store ',
|
140
|
+
'sv':' com edu gob org red ',
|
141
|
+
'sz':' ac co org ',
|
142
|
+
'tr':' av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ',
|
143
|
+
'tt':' aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ',
|
144
|
+
'tw':' club com ebiz edu game gov idv mil net org ',
|
145
|
+
'mu':' ac co com gov net or org ',
|
146
|
+
'mz':' ac co edu gov org ',
|
147
|
+
'na':' co com ',
|
148
|
+
'nz':' ac co cri geek gen govt health iwi maori mil net org parliament school ',
|
149
|
+
'pa':' abo ac com edu gob ing med net nom org sld ',
|
150
|
+
'pt':' com edu gov int net nome org publ ',
|
151
|
+
'py':' com edu gov mil net org ',
|
152
|
+
'qa':' com edu gov mil net org ',
|
153
|
+
're':' asso com nom ',
|
154
|
+
'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 ',
|
155
|
+
'rw':' ac co com edu gouv gov int mil net ',
|
156
|
+
'sa':' com edu gov med net org pub sch ',
|
157
|
+
'sd':' com edu gov info med net org tv ',
|
158
|
+
'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 ',
|
159
|
+
'sg':' com edu gov idn net org per ',
|
160
|
+
'sn':' art com edu gouv org perso univ ',
|
161
|
+
'sy':' com edu gov mil net news org ',
|
162
|
+
'th':' ac co go in mi net or ',
|
163
|
+
'tj':' ac biz co com edu go gov info int mil name net nic org test web ',
|
164
|
+
'tn':' agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ',
|
165
|
+
'tz':' ac co go ne or ',
|
166
|
+
'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 ',
|
167
|
+
'ug':' ac co go ne or org sc ',
|
168
|
+
'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 ',
|
169
|
+
'us':' dni fed isa kids nsn ',
|
170
|
+
'uy':' com edu gub mil net org ',
|
171
|
+
've':' co com edu gob info mil net org web ',
|
172
|
+
'vi':' co com k12 net org ',
|
173
|
+
'vn':' ac biz com edu gov health info int name net org pro ',
|
174
|
+
'ye':' co com gov ltd me net org plc ',
|
175
|
+
'yu':' ac co edu gov org ',
|
176
|
+
'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 ',
|
177
|
+
'zm':' ac co com edu gov net org sch '
|
178
|
+
},
|
179
|
+
// gorhill 2013-10-25: Using indexOf() instead Regexp(). Significant boost
|
180
|
+
// in both performance and memory footprint. No initialization required.
|
181
|
+
// http://jsperf.com/uri-js-sld-regex-vs-binary-search/4
|
182
|
+
// Following methods use lastIndexOf() rather than array.split() in order
|
183
|
+
// to avoid any memory allocations.
|
184
|
+
has: function(domain) {
|
185
|
+
var tldOffset = domain.lastIndexOf('.');
|
186
|
+
if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {
|
187
|
+
return false;
|
188
|
+
}
|
189
|
+
var sldOffset = domain.lastIndexOf('.', tldOffset-1);
|
190
|
+
if (sldOffset <= 0 || sldOffset >= (tldOffset-1)) {
|
191
|
+
return false;
|
192
|
+
}
|
193
|
+
var sldList = SLD.list[domain.slice(tldOffset+1)];
|
194
|
+
if (!sldList) {
|
195
|
+
return false;
|
196
|
+
}
|
197
|
+
return sldList.indexOf(' ' + domain.slice(sldOffset+1, tldOffset) + ' ') >= 0;
|
198
|
+
},
|
199
|
+
is: function(domain) {
|
200
|
+
var tldOffset = domain.lastIndexOf('.');
|
201
|
+
if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {
|
202
|
+
return false;
|
203
|
+
}
|
204
|
+
var sldOffset = domain.lastIndexOf('.', tldOffset-1);
|
205
|
+
if (sldOffset >= 0) {
|
206
|
+
return false;
|
207
|
+
}
|
208
|
+
var sldList = SLD.list[domain.slice(tldOffset+1)];
|
209
|
+
if (!sldList) {
|
210
|
+
return false;
|
211
|
+
}
|
212
|
+
return sldList.indexOf(' ' + domain.slice(0, tldOffset) + ' ') >= 0;
|
213
|
+
},
|
214
|
+
get: function(domain) {
|
215
|
+
var tldOffset = domain.lastIndexOf('.');
|
216
|
+
if (tldOffset <= 0 || tldOffset >= (domain.length-1)) {
|
217
|
+
return null;
|
218
|
+
}
|
219
|
+
var sldOffset = domain.lastIndexOf('.', tldOffset-1);
|
220
|
+
if (sldOffset <= 0 || sldOffset >= (tldOffset-1)) {
|
221
|
+
return null;
|
222
|
+
}
|
223
|
+
var sldList = SLD.list[domain.slice(tldOffset+1)];
|
224
|
+
if (!sldList) {
|
225
|
+
return null;
|
226
|
+
}
|
227
|
+
if (sldList.indexOf(' ' + domain.slice(sldOffset+1, tldOffset) + ' ') < 0) {
|
228
|
+
return null;
|
229
|
+
}
|
230
|
+
return domain.slice(sldOffset+1);
|
231
|
+
},
|
232
|
+
noConflict: function(){
|
233
|
+
if (root.SecondLevelDomains === this) {
|
234
|
+
root.SecondLevelDomains = _SecondLevelDomains;
|
235
|
+
}
|
236
|
+
return this;
|
237
|
+
}
|
238
|
+
};
|
239
|
+
|
240
|
+
return SLD;
|
241
|
+
}));
|