epuber 0.5.7 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -2
- data/README.md +20 -26
- data/bin/epuber +2 -3
- data/epuber.gemspec +10 -12
- data/lib/epuber/book/contributor.rb +1 -1
- data/lib/epuber/book/file_request.rb +1 -1
- data/lib/epuber/book/target.rb +1 -2
- data/lib/epuber/book/toc_item.rb +1 -2
- data/lib/epuber/book.rb +1 -2
- data/lib/epuber/checker/text_checker.rb +1 -1
- data/lib/epuber/checker.rb +1 -2
- data/lib/epuber/checker_transformer_base.rb +1 -0
- data/lib/epuber/command/build.rb +1 -2
- data/lib/epuber/command/compile.rb +1 -1
- data/lib/epuber/command/init.rb +1 -2
- data/lib/epuber/command/server.rb +1 -2
- data/lib/epuber/command.rb +1 -1
- data/lib/epuber/compiler/compilation_context.rb +1 -1
- data/lib/epuber/compiler/file_database.rb +3 -5
- data/lib/epuber/compiler/file_finders/abstract.rb +1 -1
- data/lib/epuber/compiler/file_finders/imaginary.rb +1 -2
- data/lib/epuber/compiler/file_finders/normal.rb +1 -1
- data/lib/epuber/compiler/file_resolver.rb +1 -2
- data/lib/epuber/compiler/file_stat.rb +0 -1
- data/lib/epuber/compiler/file_types/abstract_file.rb +1 -2
- data/lib/epuber/compiler/file_types/bade_file.rb +1 -2
- data/lib/epuber/compiler/file_types/coffee_script_file.rb +1 -2
- data/lib/epuber/compiler/file_types/container_xml_file.rb +1 -2
- data/lib/epuber/compiler/file_types/generated_file.rb +1 -2
- data/lib/epuber/compiler/file_types/ibooks_display_options_file.rb +1 -7
- data/lib/epuber/compiler/file_types/image_file.rb +1 -2
- data/lib/epuber/compiler/file_types/mime_type_file.rb +1 -2
- data/lib/epuber/compiler/file_types/nav_file.rb +1 -2
- data/lib/epuber/compiler/file_types/opf_file.rb +1 -2
- data/lib/epuber/compiler/file_types/source_file.rb +1 -2
- data/lib/epuber/compiler/file_types/static_file.rb +1 -2
- data/lib/epuber/compiler/file_types/stylus_file.rb +1 -2
- data/lib/epuber/compiler/file_types/xhtml_file.rb +2 -4
- data/lib/epuber/compiler/generator.rb +1 -1
- data/lib/epuber/compiler/meta_inf_generator.rb +1 -1
- data/lib/epuber/compiler/nav_generator.rb +1 -1
- data/lib/epuber/compiler/opf_generator.rb +1 -1
- data/lib/epuber/compiler/problem.rb +1 -2
- data/lib/epuber/compiler/xhtml_processor.rb +6 -6
- data/lib/epuber/compiler.rb +7 -11
- data/lib/epuber/config.rb +3 -4
- data/lib/epuber/dsl/attribute.rb +1 -1
- data/lib/epuber/dsl/attribute_support.rb +2 -2
- data/lib/epuber/dsl/object.rb +1 -1
- data/lib/epuber/dsl/tree_object.rb +1 -1
- data/lib/epuber/helper.rb +1 -1
- data/lib/epuber/lockfile.rb +1 -1
- data/lib/epuber/plugin.rb +1 -1
- data/lib/epuber/ruby_extensions/match_data.rb +1 -0
- data/lib/epuber/ruby_extensions/thread.rb +1 -0
- data/lib/epuber/server/handlers.rb +1 -1
- data/lib/epuber/server.rb +3 -2
- data/lib/epuber/templates.rb +2 -1
- data/lib/epuber/third_party/bower/bower.json +3 -3
- data/lib/epuber/third_party/bower/bower_components/cookies-js/bower.json +1 -1
- data/lib/epuber/third_party/bower/bower_components/cookies-js/dist/cookies.js +2 -3
- data/lib/epuber/third_party/bower/bower_components/cookies-js/dist/cookies.min.js +6 -6
- data/lib/epuber/third_party/bower/bower_components/jquery/AUTHORS.txt +278 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/{MIT-LICENSE.txt → LICENSE.txt} +17 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/README.md +65 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/bower.json +2 -16
- data/lib/epuber/third_party/bower/bower_components/jquery/dist/jquery.js +2566 -1962
- data/lib/epuber/third_party/bower/bower_components/jquery/dist/jquery.min.js +4 -5
- data/lib/epuber/third_party/bower/bower_components/jquery/dist/jquery.min.map +1 -1
- data/lib/epuber/third_party/bower/bower_components/jquery/external/sizzle/LICENSE.txt +36 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/{src → external}/sizzle/dist/sizzle.js +236 -160
- data/lib/epuber/third_party/bower/bower_components/jquery/external/sizzle/dist/sizzle.min.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/external/sizzle/dist/sizzle.min.map +1 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/jsonp.js +25 -14
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js +20 -12
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/parseJSON.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/parseXML.js +4 -5
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/script.js +16 -12
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/var/location.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/var/nonce.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/var/rquery.js +3 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/xhr.js +73 -42
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax.js +116 -57
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/attr.js +49 -48
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/classes.js +86 -67
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/prop.js +63 -32
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/support.js +6 -5
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/val.js +40 -24
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/callbacks.js +114 -87
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/access.js +11 -6
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/init.js +27 -16
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/parseHTML.js +10 -8
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/ready.js +20 -14
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/var/rsingleTag.js +4 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core.js +77 -85
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/addGetHookIf.js +5 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/adjustCSS.js +65 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/curCSS.js +20 -17
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/defaultDisplay.js +16 -14
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/hiddenVisibleSelectors.js +9 -6
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/showHide.js +48 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/support.js +86 -61
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/cssExpand.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/getStyles.js +8 -5
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/isHidden.js +6 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/rmargin.js +3 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/rnumnonpx.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/{swap.js → var/swap.js} +3 -7
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css.js +107 -55
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/Data.js +93 -74
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/{accepts.js → var/acceptData.js} +4 -6
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/var/{data_priv.js → dataPriv.js} +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/var/{data_user.js → dataUser.js} +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data.js +49 -40
- data/lib/epuber/third_party/bower/bower_components/jquery/src/deferred.js +34 -25
- data/lib/epuber/third_party/bower/bower_components/jquery/src/deprecated.js +27 -8
- data/lib/epuber/third_party/bower/bower_components/jquery/src/dimensions.js +9 -5
- data/lib/epuber/third_party/bower/bower_components/jquery/src/effects/Tween.js +14 -7
- data/lib/epuber/third_party/bower/bower_components/jquery/src/effects/animatedSelector.js +4 -4
- data/lib/epuber/third_party/bower/bower_components/jquery/src/effects.js +96 -115
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/ajax.js +11 -4
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/alias.js +11 -23
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/focusin.js +53 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/support.js +3 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/trigger.js +183 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event.js +168 -325
- data/lib/epuber/third_party/bower/bower_components/jquery/src/exports/amd.js +3 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/exports/global.js +2 -8
- data/lib/epuber/third_party/bower/bower_components/jquery/src/intro.js +1 -1
- data/lib/epuber/third_party/bower/bower_components/jquery/src/jquery.js +5 -5
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/_evalUrl.js +6 -4
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/buildFragment.js +102 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/getAll.js +21 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/setGlobalEval.js +20 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/support.js +7 -6
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/var/rcheckableType.js +3 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/var/rscriptType.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/var/rtagName.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/wrapMap.js +27 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation.js +206 -305
- data/lib/epuber/third_party/bower/bower_components/jquery/src/offset.js +40 -29
- 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/delay.js +6 -6
- data/lib/epuber/third_party/bower/bower_components/jquery/src/queue.js +23 -22
- data/lib/epuber/third_party/bower/bower_components/jquery/src/selector-native.js +107 -68
- data/lib/epuber/third_party/bower/bower_components/jquery/src/selector-sizzle.js +5 -5
- data/lib/epuber/third_party/bower/bower_components/jquery/src/selector.js +1 -1
- data/lib/epuber/third_party/bower/bower_components/jquery/src/serialize.js +28 -14
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing/findFilter.js +13 -13
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing/var/dir.js +20 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing/var/rneedsContext.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing/var/siblings.js +15 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing.js +32 -56
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/arr.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/class2type.js +3 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/concat.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/document.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/documentElement.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/hasOwn.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/indexOf.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/pnum.js +3 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/push.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/rcssNum.js +7 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/rnotwhite.js +3 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/slice.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/support.js +3 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/toString.js +2 -2
- data/lib/epuber/third_party/bower/bower_components/jquery/src/wrap.js +19 -19
- data/lib/epuber/third_party/bower/bower_components/spin.js/{LICENSE.txt → LICENSE.md} +2 -1
- data/lib/epuber/third_party/bower/bower_components/spin.js/README.md +21 -21
- data/lib/epuber/third_party/bower/bower_components/spin.js/bower.json +0 -1
- data/lib/epuber/third_party/bower/bower_components/spin.js/jquery.spin.js +23 -24
- data/lib/epuber/third_party/bower/bower_components/spin.js/spin.js +153 -113
- data/lib/epuber/third_party/bower/bower_components/spin.js/spin.min.js +2 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/CHANGELOG.md +424 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/README.md +23 -308
- data/lib/epuber/third_party/bower/bower_components/uri.js/SECURITY.md +12 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/bower.json +2 -2
- data/lib/epuber/third_party/bower/bower_components/uri.js/contributing.md +0 -4
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/IPv6.js +3 -6
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/SecondLevelDomains.js +8 -4
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.fragmentQuery.js +21 -4
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.fragmentURI.js +1 -1
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.js +312 -69
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.min.js +85 -77
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URITemplate.js +28 -11
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/jquery.URI.js +17 -18
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/jquery.URI.min.js +6 -6
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/punycode.js +63 -38
- data/lib/epuber/third_party/bower.rb +2 -0
- data/lib/epuber/transformer/text_transformer.rb +1 -2
- data/lib/epuber/transformer.rb +1 -2
- data/lib/epuber/user_interface.rb +1 -1
- data/lib/epuber/vendor/hash_binding.rb +1 -1
- data/lib/epuber/vendor/nokogiri_extensions.rb +24 -21
- data/lib/epuber/vendor/ruby_templater.rb +1 -2
- data/lib/epuber/vendor/size.rb +1 -0
- data/lib/epuber/vendor/version.rb +1 -1
- data/lib/epuber/version.rb +2 -1
- data/lib/epuber.rb +1 -1
- metadata +77 -46
- data/lib/epuber/ruby_extensions/string.rb +0 -16
- data/lib/epuber/third_party/bower/bower_components/jquery/src/sizzle/dist/sizzle.min.js +0 -3
- data/lib/epuber/third_party/bower/bower_components/jquery/src/sizzle/dist/sizzle.min.map +0 -1
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/strundefined.js +0 -3
- data/lib/epuber/vendor/globals_context.rb +0 -26
@@ -1,20 +1,19 @@
|
|
1
1
|
/*!
|
2
2
|
* URI.js - Mutating URLs
|
3
3
|
*
|
4
|
-
* Version: 1.
|
4
|
+
* Version: 1.19.10
|
5
5
|
*
|
6
6
|
* Author: Rodney Rehm
|
7
7
|
* Web: http://medialize.github.io/URI.js/
|
8
8
|
*
|
9
9
|
* Licensed under
|
10
10
|
* MIT License http://www.opensource.org/licenses/mit-license
|
11
|
-
* GPL v3 http://opensource.org/licenses/GPL-3.0
|
12
11
|
*
|
13
12
|
*/
|
14
13
|
(function (root, factory) {
|
15
14
|
'use strict';
|
16
15
|
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
17
|
-
if (typeof
|
16
|
+
if (typeof module === 'object' && module.exports) {
|
18
17
|
// Node
|
19
18
|
module.exports = factory(require('./punycode'), require('./IPv6'), require('./SecondLevelDomains'));
|
20
19
|
} else if (typeof define === 'function' && define.amd) {
|
@@ -62,6 +61,12 @@
|
|
62
61
|
}
|
63
62
|
}
|
64
63
|
|
64
|
+
if (url === null) {
|
65
|
+
if (_urlSupplied) {
|
66
|
+
throw new TypeError('null is not a valid argument for URI');
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
65
70
|
this.href(url);
|
66
71
|
|
67
72
|
// resolve to base according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#constructor
|
@@ -72,7 +77,11 @@
|
|
72
77
|
return this;
|
73
78
|
}
|
74
79
|
|
75
|
-
|
80
|
+
function isInteger(value) {
|
81
|
+
return /^[0-9]+$/.test(value);
|
82
|
+
}
|
83
|
+
|
84
|
+
URI.version = '1.19.10';
|
76
85
|
|
77
86
|
var p = URI.prototype;
|
78
87
|
var hasOwn = Object.prototype.hasOwnProperty;
|
@@ -175,6 +184,11 @@
|
|
175
184
|
return true;
|
176
185
|
}
|
177
186
|
|
187
|
+
function trimSlashes(text) {
|
188
|
+
var trim_expression = /^\/+|\/+$/g;
|
189
|
+
return text.replace(trim_expression, '');
|
190
|
+
}
|
191
|
+
|
178
192
|
URI._parts = function() {
|
179
193
|
return {
|
180
194
|
protocol: null,
|
@@ -187,17 +201,22 @@
|
|
187
201
|
query: null,
|
188
202
|
fragment: null,
|
189
203
|
// state
|
204
|
+
preventInvalidHostname: URI.preventInvalidHostname,
|
190
205
|
duplicateQueryParameters: URI.duplicateQueryParameters,
|
191
206
|
escapeQuerySpace: URI.escapeQuerySpace
|
192
207
|
};
|
193
208
|
};
|
209
|
+
// state: throw on invalid hostname
|
210
|
+
// see https://github.com/medialize/URI.js/pull/345
|
211
|
+
// and https://github.com/medialize/URI.js/issues/354
|
212
|
+
URI.preventInvalidHostname = false;
|
194
213
|
// state: allow duplicate query parameters (a=1&a=1)
|
195
214
|
URI.duplicateQueryParameters = false;
|
196
215
|
// state: replaces + with %20 (space in query strings)
|
197
216
|
URI.escapeQuerySpace = true;
|
198
217
|
// static properties
|
199
218
|
URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i;
|
200
|
-
URI.idn_expression = /[^a-z0-9
|
219
|
+
URI.idn_expression = /[^a-z0-9\._-]/i;
|
201
220
|
URI.punycode_expression = /(xn--)/i;
|
202
221
|
// well, 333.444.555.666 matches, but it sure ain't no IPv4 - do we care?
|
203
222
|
URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
@@ -216,8 +235,11 @@
|
|
216
235
|
// everything up to the next whitespace
|
217
236
|
end: /[\s\r\n]|$/,
|
218
237
|
// trim trailing punctuation captured by end RegExp
|
219
|
-
trim: /[`!()\[\]{};:'".,<>?«»“”„‘’]
|
238
|
+
trim: /[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,
|
239
|
+
// balanced parens inclusion (), [], {}, <>
|
240
|
+
parens: /(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g,
|
220
241
|
};
|
242
|
+
URI.leading_whitespace_expression = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/
|
221
243
|
// http://www.iana.org/assignments/uri-schemes.html
|
222
244
|
// http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports
|
223
245
|
URI.defaultPorts = {
|
@@ -228,10 +250,16 @@
|
|
228
250
|
ws: '80',
|
229
251
|
wss: '443'
|
230
252
|
};
|
253
|
+
// list of protocols which always require a hostname
|
254
|
+
URI.hostProtocols = [
|
255
|
+
'http',
|
256
|
+
'https'
|
257
|
+
];
|
258
|
+
|
231
259
|
// allowed hostname characters according to RFC 3986
|
232
260
|
// ALPHA DIGIT "-" "." "_" "~" "!" "$" "&" "'" "(" ")" "*" "+" "," ";" "=" %encoded
|
233
|
-
// I've never seen a (non-IDN) hostname other than: ALPHA DIGIT . -
|
234
|
-
URI.invalid_hostname_characters = /[^a-zA-Z0-9
|
261
|
+
// I've never seen a (non-IDN) hostname other than: ALPHA DIGIT . - _
|
262
|
+
URI.invalid_hostname_characters = /[^a-zA-Z0-9\.\-:_]/;
|
235
263
|
// map DOM Elements to their URI attribute
|
236
264
|
URI.domAttributes = {
|
237
265
|
'a': 'href',
|
@@ -463,8 +491,13 @@
|
|
463
491
|
URI.parse = function(string, parts) {
|
464
492
|
var pos;
|
465
493
|
if (!parts) {
|
466
|
-
parts = {
|
494
|
+
parts = {
|
495
|
+
preventInvalidHostname: URI.preventInvalidHostname
|
496
|
+
};
|
467
497
|
}
|
498
|
+
|
499
|
+
string = string.replace(URI.leading_whitespace_expression, '')
|
500
|
+
|
468
501
|
// [protocol"://"[username[":"password]"@"]hostname[":"port]"/"?][path]["?"querystring]["#"fragment]
|
469
502
|
|
470
503
|
// extract fragment
|
@@ -483,6 +516,9 @@
|
|
483
516
|
string = string.substring(0, pos);
|
484
517
|
}
|
485
518
|
|
519
|
+
// slashes and backslashes have lost all meaning for the web protocols (https, http, wss, ws)
|
520
|
+
string = string.replace(/^(https?|ftp|wss?)?:+[/\\]*/i, '$1://');
|
521
|
+
|
486
522
|
// extract protocol
|
487
523
|
if (string.substring(0, 2) === '//') {
|
488
524
|
// relative-scheme
|
@@ -497,7 +533,7 @@
|
|
497
533
|
if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {
|
498
534
|
// : may be within the path
|
499
535
|
parts.protocol = undefined;
|
500
|
-
} else if (string.substring(pos + 1, pos + 3) === '//') {
|
536
|
+
} else if (string.substring(pos + 1, pos + 3).replace(/\\/g, '/') === '//') {
|
501
537
|
string = string.substring(pos + 3);
|
502
538
|
|
503
539
|
// extract "user:pass@host:port"
|
@@ -516,6 +552,17 @@
|
|
516
552
|
return parts;
|
517
553
|
};
|
518
554
|
URI.parseHost = function(string, parts) {
|
555
|
+
if (!string) {
|
556
|
+
string = '';
|
557
|
+
}
|
558
|
+
|
559
|
+
// Copy chrome, IE, opera backslash-handling behavior.
|
560
|
+
// Back slashes before the query string get converted to forward slashes
|
561
|
+
// See: https://github.com/joyent/node/blob/386fd24f49b0e9d1a8a076592a404168faeecc34/lib/url.js#L115-L124
|
562
|
+
// See: https://code.google.com/p/chromium/issues/detail?id=25916
|
563
|
+
// https://github.com/medialize/URI.js/pull/233
|
564
|
+
string = string.replace(/\\/g, '/');
|
565
|
+
|
519
566
|
// extract host:port
|
520
567
|
var pos = string.indexOf('/');
|
521
568
|
var bracketPos;
|
@@ -556,6 +603,14 @@
|
|
556
603
|
string = '/' + string;
|
557
604
|
}
|
558
605
|
|
606
|
+
if (parts.preventInvalidHostname) {
|
607
|
+
URI.ensureValidHostname(parts.hostname, parts.protocol);
|
608
|
+
}
|
609
|
+
|
610
|
+
if (parts.port) {
|
611
|
+
URI.ensureValidPort(parts.port);
|
612
|
+
}
|
613
|
+
|
559
614
|
return string.substring(pos) || '/';
|
560
615
|
};
|
561
616
|
URI.parseAuthority = function(string, parts) {
|
@@ -564,17 +619,22 @@
|
|
564
619
|
};
|
565
620
|
URI.parseUserinfo = function(string, parts) {
|
566
621
|
// extract username:password
|
622
|
+
var _string = string
|
623
|
+
var firstBackSlash = string.indexOf('\\');
|
624
|
+
if (firstBackSlash !== -1) {
|
625
|
+
string = string.replace(/\\/g, '/')
|
626
|
+
}
|
567
627
|
var firstSlash = string.indexOf('/');
|
568
628
|
var pos = string.lastIndexOf('@', firstSlash > -1 ? firstSlash : string.length - 1);
|
569
629
|
var t;
|
570
630
|
|
571
|
-
// authority@ must come before /path
|
631
|
+
// authority@ must come before /path or \path
|
572
632
|
if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) {
|
573
633
|
t = string.substring(0, pos).split(':');
|
574
634
|
parts.username = t[0] ? URI.decode(t[0]) : null;
|
575
635
|
t.shift();
|
576
636
|
parts.password = t[0] ? URI.decode(t.join(':')) : null;
|
577
|
-
string =
|
637
|
+
string = _string.substring(pos + 1);
|
578
638
|
} else {
|
579
639
|
parts.username = null;
|
580
640
|
parts.password = null;
|
@@ -605,7 +665,10 @@
|
|
605
665
|
// no "=" is null according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#collect-url-parameters
|
606
666
|
value = v.length ? URI.decodeQuery(v.join('='), escapeQuerySpace) : null;
|
607
667
|
|
608
|
-
if (
|
668
|
+
if (name === '__proto__') {
|
669
|
+
// ignore attempt at exploiting JavaScript internals
|
670
|
+
continue;
|
671
|
+
} else if (hasOwn.call(items, name)) {
|
609
672
|
if (typeof items[name] === 'string' || items[name] === null) {
|
610
673
|
items[name] = [items[name]];
|
611
674
|
}
|
@@ -621,6 +684,7 @@
|
|
621
684
|
|
622
685
|
URI.build = function(parts) {
|
623
686
|
var t = '';
|
687
|
+
var requireAbsolutePath = false
|
624
688
|
|
625
689
|
if (parts.protocol) {
|
626
690
|
t += parts.protocol + ':';
|
@@ -628,12 +692,13 @@
|
|
628
692
|
|
629
693
|
if (!parts.urn && (t || parts.hostname)) {
|
630
694
|
t += '//';
|
695
|
+
requireAbsolutePath = true
|
631
696
|
}
|
632
697
|
|
633
698
|
t += (URI.buildAuthority(parts) || '');
|
634
699
|
|
635
700
|
if (typeof parts.path === 'string') {
|
636
|
-
if (parts.path.charAt(0) !== '/' &&
|
701
|
+
if (parts.path.charAt(0) !== '/' && requireAbsolutePath) {
|
637
702
|
t += '/';
|
638
703
|
}
|
639
704
|
|
@@ -674,11 +739,13 @@
|
|
674
739
|
|
675
740
|
if (parts.username) {
|
676
741
|
t += URI.encode(parts.username);
|
742
|
+
}
|
677
743
|
|
678
|
-
|
679
|
-
|
680
|
-
|
744
|
+
if (parts.password) {
|
745
|
+
t += ':' + URI.encode(parts.password);
|
746
|
+
}
|
681
747
|
|
748
|
+
if (t) {
|
682
749
|
t += '@';
|
683
750
|
}
|
684
751
|
|
@@ -694,7 +761,10 @@
|
|
694
761
|
var t = '';
|
695
762
|
var unique, key, i, length;
|
696
763
|
for (key in data) {
|
697
|
-
if (
|
764
|
+
if (key === '__proto__') {
|
765
|
+
// ignore attempt at exploiting JavaScript internals
|
766
|
+
continue;
|
767
|
+
} else if (hasOwn.call(data, key)) {
|
698
768
|
if (isArray(data[key])) {
|
699
769
|
unique = {};
|
700
770
|
for (i = 0, length = data[key].length; i < length; i++) {
|
@@ -743,6 +813,21 @@
|
|
743
813
|
throw new TypeError('URI.addQuery() accepts an object, string as the name parameter');
|
744
814
|
}
|
745
815
|
};
|
816
|
+
|
817
|
+
URI.setQuery = function(data, name, value) {
|
818
|
+
if (typeof name === 'object') {
|
819
|
+
for (var key in name) {
|
820
|
+
if (hasOwn.call(name, key)) {
|
821
|
+
URI.setQuery(data, key, name[key]);
|
822
|
+
}
|
823
|
+
}
|
824
|
+
} else if (typeof name === 'string') {
|
825
|
+
data[name] = value === undefined ? null : value;
|
826
|
+
} else {
|
827
|
+
throw new TypeError('URI.setQuery() accepts an object, string as the name parameter');
|
828
|
+
}
|
829
|
+
};
|
830
|
+
|
746
831
|
URI.removeQuery = function(data, name, value) {
|
747
832
|
var i, length, key;
|
748
833
|
|
@@ -770,7 +855,7 @@
|
|
770
855
|
} else {
|
771
856
|
data[name] = filterArrayValues(data[name], value);
|
772
857
|
}
|
773
|
-
} else if (data[name] === value) {
|
858
|
+
} else if (data[name] === String(value) && (!isArray(value) || value.length === 1)) {
|
774
859
|
data[name] = undefined;
|
775
860
|
} else if (isArray(data[name])) {
|
776
861
|
data[name] = filterArrayValues(data[name], value);
|
@@ -783,18 +868,35 @@
|
|
783
868
|
}
|
784
869
|
};
|
785
870
|
URI.hasQuery = function(data, name, value, withinArray) {
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
871
|
+
switch (getType(name)) {
|
872
|
+
case 'String':
|
873
|
+
// Nothing to do here
|
874
|
+
break;
|
875
|
+
|
876
|
+
case 'RegExp':
|
877
|
+
for (var key in data) {
|
878
|
+
if (hasOwn.call(data, key)) {
|
879
|
+
if (name.test(key) && (value === undefined || URI.hasQuery(data, key, value))) {
|
880
|
+
return true;
|
881
|
+
}
|
791
882
|
}
|
792
883
|
}
|
793
|
-
}
|
794
884
|
|
795
|
-
|
796
|
-
|
797
|
-
|
885
|
+
return false;
|
886
|
+
|
887
|
+
case 'Object':
|
888
|
+
for (var _key in name) {
|
889
|
+
if (hasOwn.call(name, _key)) {
|
890
|
+
if (!URI.hasQuery(data, _key, name[_key])) {
|
891
|
+
return false;
|
892
|
+
}
|
893
|
+
}
|
894
|
+
}
|
895
|
+
|
896
|
+
return true;
|
897
|
+
|
898
|
+
default:
|
899
|
+
throw new TypeError('URI.hasQuery() accepts a string, regular expression or object as the name parameter');
|
798
900
|
}
|
799
901
|
|
800
902
|
switch (getType(value)) {
|
@@ -850,6 +952,39 @@
|
|
850
952
|
};
|
851
953
|
|
852
954
|
|
955
|
+
URI.joinPaths = function() {
|
956
|
+
var input = [];
|
957
|
+
var segments = [];
|
958
|
+
var nonEmptySegments = 0;
|
959
|
+
|
960
|
+
for (var i = 0; i < arguments.length; i++) {
|
961
|
+
var url = new URI(arguments[i]);
|
962
|
+
input.push(url);
|
963
|
+
var _segments = url.segment();
|
964
|
+
for (var s = 0; s < _segments.length; s++) {
|
965
|
+
if (typeof _segments[s] === 'string') {
|
966
|
+
segments.push(_segments[s]);
|
967
|
+
}
|
968
|
+
|
969
|
+
if (_segments[s]) {
|
970
|
+
nonEmptySegments++;
|
971
|
+
}
|
972
|
+
}
|
973
|
+
}
|
974
|
+
|
975
|
+
if (!segments.length || !nonEmptySegments) {
|
976
|
+
return new URI('');
|
977
|
+
}
|
978
|
+
|
979
|
+
var uri = new URI('').segment(segments);
|
980
|
+
|
981
|
+
if (input[0].path() === '' || input[0].path().slice(0, 1) === '/') {
|
982
|
+
uri.path('/' + uri.path());
|
983
|
+
}
|
984
|
+
|
985
|
+
return uri.normalize();
|
986
|
+
};
|
987
|
+
|
853
988
|
URI.commonPath = function(one, two) {
|
854
989
|
var length = Math.min(one.length, two.length);
|
855
990
|
var pos;
|
@@ -879,6 +1014,7 @@
|
|
879
1014
|
var _start = options.start || URI.findUri.start;
|
880
1015
|
var _end = options.end || URI.findUri.end;
|
881
1016
|
var _trim = options.trim || URI.findUri.trim;
|
1017
|
+
var _parens = options.parens || URI.findUri.parens;
|
882
1018
|
var _attributeOpen = /[a-z0-9-]=["']?$/i;
|
883
1019
|
|
884
1020
|
_start.lastIndex = 0;
|
@@ -898,13 +1034,43 @@
|
|
898
1034
|
}
|
899
1035
|
|
900
1036
|
var end = start + string.slice(start).search(_end);
|
901
|
-
var slice = string.slice(start, end)
|
1037
|
+
var slice = string.slice(start, end);
|
1038
|
+
// make sure we include well balanced parens
|
1039
|
+
var parensEnd = -1;
|
1040
|
+
while (true) {
|
1041
|
+
var parensMatch = _parens.exec(slice);
|
1042
|
+
if (!parensMatch) {
|
1043
|
+
break;
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
var parensMatchEnd = parensMatch.index + parensMatch[0].length;
|
1047
|
+
parensEnd = Math.max(parensEnd, parensMatchEnd);
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
if (parensEnd > -1) {
|
1051
|
+
slice = slice.slice(0, parensEnd) + slice.slice(parensEnd).replace(_trim, '');
|
1052
|
+
} else {
|
1053
|
+
slice = slice.replace(_trim, '');
|
1054
|
+
}
|
1055
|
+
|
1056
|
+
if (slice.length <= match[0].length) {
|
1057
|
+
// the extract only contains the starting marker of a URI,
|
1058
|
+
// e.g. "www" or "http://"
|
1059
|
+
continue;
|
1060
|
+
}
|
1061
|
+
|
902
1062
|
if (options.ignore && options.ignore.test(slice)) {
|
903
1063
|
continue;
|
904
1064
|
}
|
905
1065
|
|
906
1066
|
end = start + slice.length;
|
907
1067
|
var result = callback(slice, start, end, string);
|
1068
|
+
if (result === undefined) {
|
1069
|
+
_start.lastIndex = end;
|
1070
|
+
continue;
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
result = String(result);
|
908
1074
|
string = string.slice(0, start) + result + string.slice(end);
|
909
1075
|
_start.lastIndex = start + result.length;
|
910
1076
|
}
|
@@ -913,22 +1079,44 @@
|
|
913
1079
|
return string;
|
914
1080
|
};
|
915
1081
|
|
916
|
-
URI.ensureValidHostname = function(v) {
|
1082
|
+
URI.ensureValidHostname = function(v, protocol) {
|
917
1083
|
// Theoretically URIs allow percent-encoding in Hostnames (according to RFC 3986)
|
918
1084
|
// they are not part of DNS and therefore ignored by URI.js
|
919
1085
|
|
920
|
-
|
1086
|
+
var hasHostname = !!v; // not null and not an empty string
|
1087
|
+
var hasProtocol = !!protocol;
|
1088
|
+
var rejectEmptyHostname = false;
|
1089
|
+
|
1090
|
+
if (hasProtocol) {
|
1091
|
+
rejectEmptyHostname = arrayContains(URI.hostProtocols, protocol);
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
if (rejectEmptyHostname && !hasHostname) {
|
1095
|
+
throw new TypeError('Hostname cannot be empty, if protocol is ' + protocol);
|
1096
|
+
} else if (v && v.match(URI.invalid_hostname_characters)) {
|
921
1097
|
// test punycode
|
922
1098
|
if (!punycode) {
|
923
|
-
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9
|
1099
|
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');
|
924
1100
|
}
|
925
|
-
|
926
1101
|
if (punycode.toASCII(v).match(URI.invalid_hostname_characters)) {
|
927
|
-
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9
|
1102
|
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-:_]');
|
928
1103
|
}
|
929
1104
|
}
|
930
1105
|
};
|
931
1106
|
|
1107
|
+
URI.ensureValidPort = function (v) {
|
1108
|
+
if (!v) {
|
1109
|
+
return;
|
1110
|
+
}
|
1111
|
+
|
1112
|
+
var port = Number(v);
|
1113
|
+
if (isInteger(port) && (port > 0) && (port < 65536)) {
|
1114
|
+
return;
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
throw new TypeError('Port "' + v + '" is not a valid port');
|
1118
|
+
};
|
1119
|
+
|
932
1120
|
// noConflict
|
933
1121
|
URI.noConflict = function(removeAll) {
|
934
1122
|
if (removeAll) {
|
@@ -1073,10 +1261,14 @@
|
|
1073
1261
|
} else if (_URI || _object) {
|
1074
1262
|
var src = _URI ? href._parts : href;
|
1075
1263
|
for (key in src) {
|
1264
|
+
if (key === 'query') { continue; }
|
1076
1265
|
if (hasOwn.call(this._parts, key)) {
|
1077
1266
|
this._parts[key] = src[key];
|
1078
1267
|
}
|
1079
1268
|
}
|
1269
|
+
if (src.query) {
|
1270
|
+
this.query(src.query, false);
|
1271
|
+
}
|
1080
1272
|
} else {
|
1081
1273
|
throw new TypeError('invalid input');
|
1082
1274
|
}
|
@@ -1157,16 +1349,15 @@
|
|
1157
1349
|
var _hostname = p.hostname;
|
1158
1350
|
|
1159
1351
|
p.protocol = function(v, build) {
|
1160
|
-
if (v
|
1161
|
-
|
1162
|
-
|
1163
|
-
v = v.replace(/:(\/\/)?$/, '');
|
1352
|
+
if (v) {
|
1353
|
+
// accept trailing ://
|
1354
|
+
v = v.replace(/:(\/\/)?$/, '');
|
1164
1355
|
|
1165
|
-
|
1166
|
-
|
1167
|
-
}
|
1356
|
+
if (!v.match(URI.protocol_expression)) {
|
1357
|
+
throw new TypeError('Protocol "' + v + '" contains characters other than [A-Z0-9.+-] or doesn\'t start with [A-Z]');
|
1168
1358
|
}
|
1169
1359
|
}
|
1360
|
+
|
1170
1361
|
return _protocol.call(this, v, build);
|
1171
1362
|
};
|
1172
1363
|
p.scheme = p.protocol;
|
@@ -1186,9 +1377,7 @@
|
|
1186
1377
|
v = v.substring(1);
|
1187
1378
|
}
|
1188
1379
|
|
1189
|
-
|
1190
|
-
throw new TypeError('Port "' + v + '" contains characters other than [0-9]');
|
1191
|
-
}
|
1380
|
+
URI.ensureValidPort(v);
|
1192
1381
|
}
|
1193
1382
|
}
|
1194
1383
|
return _port.call(this, v, build);
|
@@ -1199,14 +1388,44 @@
|
|
1199
1388
|
}
|
1200
1389
|
|
1201
1390
|
if (v !== undefined) {
|
1202
|
-
var x = {};
|
1203
|
-
URI.parseHost(v, x);
|
1391
|
+
var x = { preventInvalidHostname: this._parts.preventInvalidHostname };
|
1392
|
+
var res = URI.parseHost(v, x);
|
1393
|
+
if (res !== '/') {
|
1394
|
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
|
1395
|
+
}
|
1396
|
+
|
1204
1397
|
v = x.hostname;
|
1398
|
+
if (this._parts.preventInvalidHostname) {
|
1399
|
+
URI.ensureValidHostname(v, this._parts.protocol);
|
1400
|
+
}
|
1205
1401
|
}
|
1402
|
+
|
1206
1403
|
return _hostname.call(this, v, build);
|
1207
1404
|
};
|
1208
1405
|
|
1209
1406
|
// compound accessors
|
1407
|
+
p.origin = function(v, build) {
|
1408
|
+
if (this._parts.urn) {
|
1409
|
+
return v === undefined ? '' : this;
|
1410
|
+
}
|
1411
|
+
|
1412
|
+
if (v === undefined) {
|
1413
|
+
var protocol = this.protocol();
|
1414
|
+
var authority = this.authority();
|
1415
|
+
if (!authority) {
|
1416
|
+
return '';
|
1417
|
+
}
|
1418
|
+
|
1419
|
+
return (protocol ? protocol + '://' : '') + this.authority();
|
1420
|
+
} else {
|
1421
|
+
var origin = URI(v);
|
1422
|
+
this
|
1423
|
+
.protocol(origin.protocol())
|
1424
|
+
.authority(origin.authority())
|
1425
|
+
.build(!build);
|
1426
|
+
return this;
|
1427
|
+
}
|
1428
|
+
};
|
1210
1429
|
p.host = function(v, build) {
|
1211
1430
|
if (this._parts.urn) {
|
1212
1431
|
return v === undefined ? '' : this;
|
@@ -1215,7 +1434,11 @@
|
|
1215
1434
|
if (v === undefined) {
|
1216
1435
|
return this._parts.hostname ? URI.buildHost(this._parts) : '';
|
1217
1436
|
} else {
|
1218
|
-
URI.parseHost(v, this._parts);
|
1437
|
+
var res = URI.parseHost(v, this._parts);
|
1438
|
+
if (res !== '/') {
|
1439
|
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
|
1440
|
+
}
|
1441
|
+
|
1219
1442
|
this.build(!build);
|
1220
1443
|
return this;
|
1221
1444
|
}
|
@@ -1228,7 +1451,11 @@
|
|
1228
1451
|
if (v === undefined) {
|
1229
1452
|
return this._parts.hostname ? URI.buildAuthority(this._parts) : '';
|
1230
1453
|
} else {
|
1231
|
-
URI.parseAuthority(v, this._parts);
|
1454
|
+
var res = URI.parseAuthority(v, this._parts);
|
1455
|
+
if (res !== '/') {
|
1456
|
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
|
1457
|
+
}
|
1458
|
+
|
1232
1459
|
this.build(!build);
|
1233
1460
|
return this;
|
1234
1461
|
}
|
@@ -1239,12 +1466,8 @@
|
|
1239
1466
|
}
|
1240
1467
|
|
1241
1468
|
if (v === undefined) {
|
1242
|
-
if (!this._parts.username) {
|
1243
|
-
return '';
|
1244
|
-
}
|
1245
|
-
|
1246
1469
|
var t = URI.buildUserinfo(this._parts);
|
1247
|
-
return t.substring(0, t.length -1);
|
1470
|
+
return t ? t.substring(0, t.length -1) : t;
|
1248
1471
|
} else {
|
1249
1472
|
if (v[v.length-1] !== '@') {
|
1250
1473
|
v += '@';
|
@@ -1294,8 +1517,12 @@
|
|
1294
1517
|
v += '.';
|
1295
1518
|
}
|
1296
1519
|
|
1520
|
+
if (v.indexOf(':') !== -1) {
|
1521
|
+
throw new TypeError('Domains cannot contain colons');
|
1522
|
+
}
|
1523
|
+
|
1297
1524
|
if (v) {
|
1298
|
-
URI.ensureValidHostname(v);
|
1525
|
+
URI.ensureValidHostname(v, this._parts.protocol);
|
1299
1526
|
}
|
1300
1527
|
|
1301
1528
|
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
@@ -1334,7 +1561,11 @@
|
|
1334
1561
|
throw new TypeError('cannot set domain empty');
|
1335
1562
|
}
|
1336
1563
|
|
1337
|
-
|
1564
|
+
if (v.indexOf(':') !== -1) {
|
1565
|
+
throw new TypeError('Domains cannot contain colons');
|
1566
|
+
}
|
1567
|
+
|
1568
|
+
URI.ensureValidHostname(v, this._parts.protocol);
|
1338
1569
|
|
1339
1570
|
if (!this._parts.hostname || this.is('IP')) {
|
1340
1571
|
this._parts.hostname = v;
|
@@ -1445,7 +1676,7 @@
|
|
1445
1676
|
return v === undefined ? '' : this;
|
1446
1677
|
}
|
1447
1678
|
|
1448
|
-
if (
|
1679
|
+
if (typeof v !== 'string') {
|
1449
1680
|
if (!this._parts.path || this._parts.path === '/') {
|
1450
1681
|
return '';
|
1451
1682
|
}
|
@@ -1573,9 +1804,10 @@
|
|
1573
1804
|
segments.pop();
|
1574
1805
|
}
|
1575
1806
|
|
1576
|
-
segments.push(v[i]);
|
1807
|
+
segments.push(trimSlashes(v[i]));
|
1577
1808
|
}
|
1578
1809
|
} else if (v || typeof v === 'string') {
|
1810
|
+
v = trimSlashes(v);
|
1579
1811
|
if (segments[segments.length -1] === '') {
|
1580
1812
|
// empty trailing elements have to be overwritten
|
1581
1813
|
// to prevent results such as /foo//bar
|
@@ -1586,7 +1818,7 @@
|
|
1586
1818
|
}
|
1587
1819
|
} else {
|
1588
1820
|
if (v) {
|
1589
|
-
segments[segment] = v;
|
1821
|
+
segments[segment] = trimSlashes(v);
|
1590
1822
|
} else {
|
1591
1823
|
segments.splice(segment, 1);
|
1592
1824
|
}
|
@@ -1771,6 +2003,8 @@
|
|
1771
2003
|
return this;
|
1772
2004
|
}
|
1773
2005
|
|
2006
|
+
_path = URI.recodePath(_path);
|
2007
|
+
|
1774
2008
|
var _was_relative;
|
1775
2009
|
var _leadingParents = '';
|
1776
2010
|
var _parent, _pos;
|
@@ -1801,7 +2035,7 @@
|
|
1801
2035
|
|
1802
2036
|
// resolve parents
|
1803
2037
|
while (true) {
|
1804
|
-
_parent = _path.
|
2038
|
+
_parent = _path.search(/\/\.\.(\/|$)/);
|
1805
2039
|
if (_parent === -1) {
|
1806
2040
|
// no more ../ to resolve
|
1807
2041
|
break;
|
@@ -1823,7 +2057,6 @@
|
|
1823
2057
|
_path = _leadingParents + _path.substring(1);
|
1824
2058
|
}
|
1825
2059
|
|
1826
|
-
_path = URI.recodePath(_path);
|
1827
2060
|
this._parts.path = _path;
|
1828
2061
|
this.build(!build);
|
1829
2062
|
return this;
|
@@ -1943,7 +2176,10 @@
|
|
1943
2176
|
base = new URI(base);
|
1944
2177
|
}
|
1945
2178
|
|
1946
|
-
if (
|
2179
|
+
if (resolved._parts.protocol) {
|
2180
|
+
// Directly returns even if this._parts.hostname is empty.
|
2181
|
+
return resolved;
|
2182
|
+
} else {
|
1947
2183
|
resolved._parts.protocol = base._parts.protocol;
|
1948
2184
|
}
|
1949
2185
|
|
@@ -1960,15 +2196,17 @@
|
|
1960
2196
|
if (!resolved._parts.query) {
|
1961
2197
|
resolved._parts.query = base._parts.query;
|
1962
2198
|
}
|
1963
|
-
} else
|
1964
|
-
resolved._parts.path
|
1965
|
-
|
2199
|
+
} else {
|
2200
|
+
if (resolved._parts.path.substring(-2) === '..') {
|
2201
|
+
resolved._parts.path += '/';
|
2202
|
+
}
|
1966
2203
|
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
2204
|
+
if (resolved.path().charAt(0) !== '/') {
|
2205
|
+
basedir = base.directory();
|
2206
|
+
basedir = basedir ? basedir : base.path().indexOf('/') === 0 ? '/' : '';
|
2207
|
+
resolved._parts.path = (basedir ? (basedir + '/') : '') + resolved._parts.path;
|
2208
|
+
resolved.normalizePath();
|
2209
|
+
}
|
1972
2210
|
}
|
1973
2211
|
|
1974
2212
|
resolved.build();
|
@@ -2101,6 +2339,11 @@
|
|
2101
2339
|
};
|
2102
2340
|
|
2103
2341
|
// state
|
2342
|
+
p.preventInvalidHostname = function(v) {
|
2343
|
+
this._parts.preventInvalidHostname = !!v;
|
2344
|
+
return this;
|
2345
|
+
};
|
2346
|
+
|
2104
2347
|
p.duplicateQueryParameters = function(v) {
|
2105
2348
|
this._parts.duplicateQueryParameters = !!v;
|
2106
2349
|
return this;
|