You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1119 lines
32 KiB
1119 lines
32 KiB
this["wp"] = this["wp"] || {}; this["wp"]["url"] = |
|
/******/ (function(modules) { // webpackBootstrap |
|
/******/ // The module cache |
|
/******/ var installedModules = {}; |
|
/******/ |
|
/******/ // The require function |
|
/******/ function __webpack_require__(moduleId) { |
|
/******/ |
|
/******/ // Check if module is in cache |
|
/******/ if(installedModules[moduleId]) { |
|
/******/ return installedModules[moduleId].exports; |
|
/******/ } |
|
/******/ // Create a new module (and put it into the cache) |
|
/******/ var module = installedModules[moduleId] = { |
|
/******/ i: moduleId, |
|
/******/ l: false, |
|
/******/ exports: {} |
|
/******/ }; |
|
/******/ |
|
/******/ // Execute the module function |
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
/******/ |
|
/******/ // Flag the module as loaded |
|
/******/ module.l = true; |
|
/******/ |
|
/******/ // Return the exports of the module |
|
/******/ return module.exports; |
|
/******/ } |
|
/******/ |
|
/******/ |
|
/******/ // expose the modules object (__webpack_modules__) |
|
/******/ __webpack_require__.m = modules; |
|
/******/ |
|
/******/ // expose the module cache |
|
/******/ __webpack_require__.c = installedModules; |
|
/******/ |
|
/******/ // define getter function for harmony exports |
|
/******/ __webpack_require__.d = function(exports, name, getter) { |
|
/******/ if(!__webpack_require__.o(exports, name)) { |
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
/******/ } |
|
/******/ }; |
|
/******/ |
|
/******/ // define __esModule on exports |
|
/******/ __webpack_require__.r = function(exports) { |
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
/******/ } |
|
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
/******/ }; |
|
/******/ |
|
/******/ // create a fake namespace object |
|
/******/ // mode & 1: value is a module id, require it |
|
/******/ // mode & 2: merge all properties of value into the ns |
|
/******/ // mode & 4: return value when already ns object |
|
/******/ // mode & 8|1: behave like require |
|
/******/ __webpack_require__.t = function(value, mode) { |
|
/******/ if(mode & 1) value = __webpack_require__(value); |
|
/******/ if(mode & 8) return value; |
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
/******/ var ns = Object.create(null); |
|
/******/ __webpack_require__.r(ns); |
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
/******/ return ns; |
|
/******/ }; |
|
/******/ |
|
/******/ // getDefaultExport function for compatibility with non-harmony modules |
|
/******/ __webpack_require__.n = function(module) { |
|
/******/ var getter = module && module.__esModule ? |
|
/******/ function getDefault() { return module['default']; } : |
|
/******/ function getModuleExports() { return module; }; |
|
/******/ __webpack_require__.d(getter, 'a', getter); |
|
/******/ return getter; |
|
/******/ }; |
|
/******/ |
|
/******/ // Object.prototype.hasOwnProperty.call |
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
/******/ |
|
/******/ // __webpack_public_path__ |
|
/******/ __webpack_require__.p = ""; |
|
/******/ |
|
/******/ |
|
/******/ // Load entry module and return exports |
|
/******/ return __webpack_require__(__webpack_require__.s = 299); |
|
/******/ }) |
|
/************************************************************************/ |
|
/******/ ({ |
|
|
|
/***/ 15: |
|
/***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
|
|
"use strict"; |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
|
function _defineProperty(obj, key, value) { |
|
if (key in obj) { |
|
Object.defineProperty(obj, key, { |
|
value: value, |
|
enumerable: true, |
|
configurable: true, |
|
writable: true |
|
}); |
|
} else { |
|
obj[key] = value; |
|
} |
|
|
|
return obj; |
|
} |
|
|
|
/***/ }), |
|
|
|
/***/ 179: |
|
/***/ (function(module, exports, __webpack_require__) { |
|
|
|
"use strict"; |
|
|
|
|
|
var has = Object.prototype.hasOwnProperty; |
|
|
|
var hexTable = (function () { |
|
var array = []; |
|
for (var i = 0; i < 256; ++i) { |
|
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); |
|
} |
|
|
|
return array; |
|
}()); |
|
|
|
var compactQueue = function compactQueue(queue) { |
|
var obj; |
|
|
|
while (queue.length) { |
|
var item = queue.pop(); |
|
obj = item.obj[item.prop]; |
|
|
|
if (Array.isArray(obj)) { |
|
var compacted = []; |
|
|
|
for (var j = 0; j < obj.length; ++j) { |
|
if (typeof obj[j] !== 'undefined') { |
|
compacted.push(obj[j]); |
|
} |
|
} |
|
|
|
item.obj[item.prop] = compacted; |
|
} |
|
} |
|
|
|
return obj; |
|
}; |
|
|
|
var arrayToObject = function arrayToObject(source, options) { |
|
var obj = options && options.plainObjects ? Object.create(null) : {}; |
|
for (var i = 0; i < source.length; ++i) { |
|
if (typeof source[i] !== 'undefined') { |
|
obj[i] = source[i]; |
|
} |
|
} |
|
|
|
return obj; |
|
}; |
|
|
|
var merge = function merge(target, source, options) { |
|
if (!source) { |
|
return target; |
|
} |
|
|
|
if (typeof source !== 'object') { |
|
if (Array.isArray(target)) { |
|
target.push(source); |
|
} else if (typeof target === 'object') { |
|
if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) { |
|
target[source] = true; |
|
} |
|
} else { |
|
return [target, source]; |
|
} |
|
|
|
return target; |
|
} |
|
|
|
if (typeof target !== 'object') { |
|
return [target].concat(source); |
|
} |
|
|
|
var mergeTarget = target; |
|
if (Array.isArray(target) && !Array.isArray(source)) { |
|
mergeTarget = arrayToObject(target, options); |
|
} |
|
|
|
if (Array.isArray(target) && Array.isArray(source)) { |
|
source.forEach(function (item, i) { |
|
if (has.call(target, i)) { |
|
if (target[i] && typeof target[i] === 'object') { |
|
target[i] = merge(target[i], item, options); |
|
} else { |
|
target.push(item); |
|
} |
|
} else { |
|
target[i] = item; |
|
} |
|
}); |
|
return target; |
|
} |
|
|
|
return Object.keys(source).reduce(function (acc, key) { |
|
var value = source[key]; |
|
|
|
if (has.call(acc, key)) { |
|
acc[key] = merge(acc[key], value, options); |
|
} else { |
|
acc[key] = value; |
|
} |
|
return acc; |
|
}, mergeTarget); |
|
}; |
|
|
|
var assign = function assignSingleSource(target, source) { |
|
return Object.keys(source).reduce(function (acc, key) { |
|
acc[key] = source[key]; |
|
return acc; |
|
}, target); |
|
}; |
|
|
|
var decode = function (str) { |
|
try { |
|
return decodeURIComponent(str.replace(/\+/g, ' ')); |
|
} catch (e) { |
|
return str; |
|
} |
|
}; |
|
|
|
var encode = function encode(str) { |
|
// This code was originally written by Brian White (mscdex) for the io.js core querystring library. |
|
// It has been adapted here for stricter adherence to RFC 3986 |
|
if (str.length === 0) { |
|
return str; |
|
} |
|
|
|
var string = typeof str === 'string' ? str : String(str); |
|
|
|
var out = ''; |
|
for (var i = 0; i < string.length; ++i) { |
|
var c = string.charCodeAt(i); |
|
|
|
if ( |
|
c === 0x2D // - |
|
|| c === 0x2E // . |
|
|| c === 0x5F // _ |
|
|| c === 0x7E // ~ |
|
|| (c >= 0x30 && c <= 0x39) // 0-9 |
|
|| (c >= 0x41 && c <= 0x5A) // a-z |
|
|| (c >= 0x61 && c <= 0x7A) // A-Z |
|
) { |
|
out += string.charAt(i); |
|
continue; |
|
} |
|
|
|
if (c < 0x80) { |
|
out = out + hexTable[c]; |
|
continue; |
|
} |
|
|
|
if (c < 0x800) { |
|
out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); |
|
continue; |
|
} |
|
|
|
if (c < 0xD800 || c >= 0xE000) { |
|
out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); |
|
continue; |
|
} |
|
|
|
i += 1; |
|
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); |
|
out += hexTable[0xF0 | (c >> 18)] |
|
+ hexTable[0x80 | ((c >> 12) & 0x3F)] |
|
+ hexTable[0x80 | ((c >> 6) & 0x3F)] |
|
+ hexTable[0x80 | (c & 0x3F)]; |
|
} |
|
|
|
return out; |
|
}; |
|
|
|
var compact = function compact(value) { |
|
var queue = [{ obj: { o: value }, prop: 'o' }]; |
|
var refs = []; |
|
|
|
for (var i = 0; i < queue.length; ++i) { |
|
var item = queue[i]; |
|
var obj = item.obj[item.prop]; |
|
|
|
var keys = Object.keys(obj); |
|
for (var j = 0; j < keys.length; ++j) { |
|
var key = keys[j]; |
|
var val = obj[key]; |
|
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { |
|
queue.push({ obj: obj, prop: key }); |
|
refs.push(val); |
|
} |
|
} |
|
} |
|
|
|
return compactQueue(queue); |
|
}; |
|
|
|
var isRegExp = function isRegExp(obj) { |
|
return Object.prototype.toString.call(obj) === '[object RegExp]'; |
|
}; |
|
|
|
var isBuffer = function isBuffer(obj) { |
|
if (obj === null || typeof obj === 'undefined') { |
|
return false; |
|
} |
|
|
|
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); |
|
}; |
|
|
|
module.exports = { |
|
arrayToObject: arrayToObject, |
|
assign: assign, |
|
compact: compact, |
|
decode: decode, |
|
encode: encode, |
|
isBuffer: isBuffer, |
|
isRegExp: isRegExp, |
|
merge: merge |
|
}; |
|
|
|
|
|
/***/ }), |
|
|
|
/***/ 180: |
|
/***/ (function(module, exports, __webpack_require__) { |
|
|
|
"use strict"; |
|
|
|
|
|
var replace = String.prototype.replace; |
|
var percentTwenties = /%20/g; |
|
|
|
module.exports = { |
|
'default': 'RFC3986', |
|
formatters: { |
|
RFC1738: function (value) { |
|
return replace.call(value, percentTwenties, '+'); |
|
}, |
|
RFC3986: function (value) { |
|
return value; |
|
} |
|
}, |
|
RFC1738: 'RFC1738', |
|
RFC3986: 'RFC3986' |
|
}; |
|
|
|
|
|
/***/ }), |
|
|
|
/***/ 299: |
|
/***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
|
|
"use strict"; |
|
__webpack_require__.r(__webpack_exports__); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isURL", function() { return isURL; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getProtocol", function() { return getProtocol; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidProtocol", function() { return isValidProtocol; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAuthority", function() { return getAuthority; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidAuthority", function() { return isValidAuthority; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getPath", function() { return getPath; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidPath", function() { return isValidPath; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQueryString", function() { return getQueryString; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidQueryString", function() { return isValidQueryString; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFragment", function() { return getFragment; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidFragment", function() { return isValidFragment; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addQueryArgs", function() { return addQueryArgs; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQueryArg", function() { return getQueryArg; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasQueryArg", function() { return hasQueryArg; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeQueryArgs", function() { return removeQueryArgs; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prependHTTP", function() { return prependHTTP; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeDecodeURI", function() { return safeDecodeURI; }); |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterURLForDisplay", function() { return filterURLForDisplay; }); |
|
/* harmony import */ var _babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8); |
|
/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(76); |
|
/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_1__); |
|
|
|
|
|
/** |
|
* External dependencies |
|
*/ |
|
|
|
var URL_REGEXP = /^(?:https?:)?\/\/\S+$/i; |
|
var EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i; |
|
var USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i; |
|
/** |
|
* Determines whether the given string looks like a URL. |
|
* |
|
* @param {string} url The string to scrutinise. |
|
* |
|
* @return {boolean} Whether or not it looks like a URL. |
|
*/ |
|
|
|
function isURL(url) { |
|
return URL_REGEXP.test(url); |
|
} |
|
/** |
|
* Returns the protocol part of the URL. |
|
* |
|
* @param {string} url The full URL. |
|
* |
|
* @return {?string} The protocol part of the URL. |
|
*/ |
|
|
|
function getProtocol(url) { |
|
var matches = /^([^\s:]+:)/.exec(url); |
|
|
|
if (matches) { |
|
return matches[1]; |
|
} |
|
} |
|
/** |
|
* Tests if a url protocol is valid. |
|
* |
|
* @param {string} protocol The url protocol. |
|
* |
|
* @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:). |
|
*/ |
|
|
|
function isValidProtocol(protocol) { |
|
if (!protocol) { |
|
return false; |
|
} |
|
|
|
return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol); |
|
} |
|
/** |
|
* Returns the authority part of the URL. |
|
* |
|
* @param {string} url The full URL. |
|
* |
|
* @return {?string} The authority part of the URL. |
|
*/ |
|
|
|
function getAuthority(url) { |
|
var matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url); |
|
|
|
if (matches) { |
|
return matches[1]; |
|
} |
|
} |
|
/** |
|
* Checks for invalid characters within the provided authority. |
|
* |
|
* @param {string} authority A string containing the URL authority. |
|
* |
|
* @return {boolean} True if the argument contains a valid authority. |
|
*/ |
|
|
|
function isValidAuthority(authority) { |
|
if (!authority) { |
|
return false; |
|
} |
|
|
|
return /^[^\s#?]+$/.test(authority); |
|
} |
|
/** |
|
* Returns the path part of the URL. |
|
* |
|
* @param {string} url The full URL. |
|
* |
|
* @return {?string} The path part of the URL. |
|
*/ |
|
|
|
function getPath(url) { |
|
var matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url); |
|
|
|
if (matches) { |
|
return matches[1]; |
|
} |
|
} |
|
/** |
|
* Checks for invalid characters within the provided path. |
|
* |
|
* @param {string} path The URL path. |
|
* |
|
* @return {boolean} True if the argument contains a valid path |
|
*/ |
|
|
|
function isValidPath(path) { |
|
if (!path) { |
|
return false; |
|
} |
|
|
|
return /^[^\s#?]+$/.test(path); |
|
} |
|
/** |
|
* Returns the query string part of the URL. |
|
* |
|
* @param {string} url The full URL. |
|
* |
|
* @return {?string} The query string part of the URL. |
|
*/ |
|
|
|
function getQueryString(url) { |
|
var matches = /^\S+?\?([^\s#]+)/.exec(url); |
|
|
|
if (matches) { |
|
return matches[1]; |
|
} |
|
} |
|
/** |
|
* Checks for invalid characters within the provided query string. |
|
* |
|
* @param {string} queryString The query string. |
|
* |
|
* @return {boolean} True if the argument contains a valid query string. |
|
*/ |
|
|
|
function isValidQueryString(queryString) { |
|
if (!queryString) { |
|
return false; |
|
} |
|
|
|
return /^[^\s#?\/]+$/.test(queryString); |
|
} |
|
/** |
|
* Returns the fragment part of the URL. |
|
* |
|
* @param {string} url The full URL |
|
* |
|
* @return {?string} The fragment part of the URL. |
|
*/ |
|
|
|
function getFragment(url) { |
|
var matches = /^\S+?(#[^\s\?]*)/.exec(url); |
|
|
|
if (matches) { |
|
return matches[1]; |
|
} |
|
} |
|
/** |
|
* Checks for invalid characters within the provided fragment. |
|
* |
|
* @param {string} fragment The url fragment. |
|
* |
|
* @return {boolean} True if the argument contains a valid fragment. |
|
*/ |
|
|
|
function isValidFragment(fragment) { |
|
if (!fragment) { |
|
return false; |
|
} |
|
|
|
return /^#[^\s#?\/]*$/.test(fragment); |
|
} |
|
/** |
|
* Appends arguments to the query string of the url |
|
* |
|
* @param {string} url URL |
|
* @param {Object} args Query Args |
|
* |
|
* @return {string} Updated URL |
|
*/ |
|
|
|
function addQueryArgs(url, args) { |
|
var queryStringIndex = url.indexOf('?'); |
|
var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_1__["parse"])(url.substr(queryStringIndex + 1)) : {}; |
|
var baseUrl = queryStringIndex !== -1 ? url.substr(0, queryStringIndex) : url; |
|
return baseUrl + '?' + Object(qs__WEBPACK_IMPORTED_MODULE_1__["stringify"])(Object(_babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])({}, query, args)); |
|
} |
|
/** |
|
* Returns a single query argument of the url |
|
* |
|
* @param {string} url URL |
|
* @param {string} arg Query arg name |
|
* |
|
* @return {Array|string} Query arg value. |
|
*/ |
|
|
|
function getQueryArg(url, arg) { |
|
var queryStringIndex = url.indexOf('?'); |
|
var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_1__["parse"])(url.substr(queryStringIndex + 1)) : {}; |
|
return query[arg]; |
|
} |
|
/** |
|
* Determines whether the URL contains a given query arg. |
|
* |
|
* @param {string} url URL |
|
* @param {string} arg Query arg name |
|
* |
|
* @return {boolean} Whether or not the URL contains the query aeg. |
|
*/ |
|
|
|
function hasQueryArg(url, arg) { |
|
return getQueryArg(url, arg) !== undefined; |
|
} |
|
/** |
|
* Removes arguments from the query string of the url |
|
* |
|
* @param {string} url URL |
|
* @param {...string} args Query Args |
|
* |
|
* @return {string} Updated URL |
|
*/ |
|
|
|
function removeQueryArgs(url) { |
|
var queryStringIndex = url.indexOf('?'); |
|
var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_1__["parse"])(url.substr(queryStringIndex + 1)) : {}; |
|
var baseUrl = queryStringIndex !== -1 ? url.substr(0, queryStringIndex) : url; |
|
|
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
args[_key - 1] = arguments[_key]; |
|
} |
|
|
|
args.forEach(function (arg) { |
|
return delete query[arg]; |
|
}); |
|
return baseUrl + '?' + Object(qs__WEBPACK_IMPORTED_MODULE_1__["stringify"])(query); |
|
} |
|
/** |
|
* Prepends "http://" to a url, if it looks like something that is meant to be a TLD. |
|
* |
|
* @param {string} url The URL to test |
|
* |
|
* @return {string} The updated URL |
|
*/ |
|
|
|
function prependHTTP(url) { |
|
if (!USABLE_HREF_REGEXP.test(url) && !EMAIL_REGEXP.test(url)) { |
|
return 'http://' + url; |
|
} |
|
|
|
return url; |
|
} |
|
/** |
|
* Safely decodes a URI with `decodeURI`. Returns the URI unmodified if |
|
* `decodeURI` throws an error. |
|
* |
|
* @param {string} uri URI to decode. |
|
* |
|
* @return {string} Decoded URI if possible. |
|
*/ |
|
|
|
function safeDecodeURI(uri) { |
|
try { |
|
return decodeURI(uri); |
|
} catch (uriError) { |
|
return uri; |
|
} |
|
} |
|
/** |
|
* Returns a URL for display. |
|
* |
|
* @param {string} url Original URL. |
|
* |
|
* @return {string} Displayed URL. |
|
*/ |
|
|
|
function filterURLForDisplay(url) { |
|
// Remove protocol and www prefixes. |
|
var filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it. |
|
|
|
if (filteredURL.match(/^[^\/]+\/$/)) { |
|
return filteredURL.replace('/', ''); |
|
} |
|
|
|
return filteredURL; |
|
} |
|
|
|
|
|
/***/ }), |
|
|
|
/***/ 300: |
|
/***/ (function(module, exports, __webpack_require__) { |
|
|
|
"use strict"; |
|
|
|
|
|
var utils = __webpack_require__(179); |
|
var formats = __webpack_require__(180); |
|
|
|
var arrayPrefixGenerators = { |
|
brackets: function brackets(prefix) { // eslint-disable-line func-name-matching |
|
return prefix + '[]'; |
|
}, |
|
indices: function indices(prefix, key) { // eslint-disable-line func-name-matching |
|
return prefix + '[' + key + ']'; |
|
}, |
|
repeat: function repeat(prefix) { // eslint-disable-line func-name-matching |
|
return prefix; |
|
} |
|
}; |
|
|
|
var toISO = Date.prototype.toISOString; |
|
|
|
var defaults = { |
|
delimiter: '&', |
|
encode: true, |
|
encoder: utils.encode, |
|
encodeValuesOnly: false, |
|
serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching |
|
return toISO.call(date); |
|
}, |
|
skipNulls: false, |
|
strictNullHandling: false |
|
}; |
|
|
|
var stringify = function stringify( // eslint-disable-line func-name-matching |
|
object, |
|
prefix, |
|
generateArrayPrefix, |
|
strictNullHandling, |
|
skipNulls, |
|
encoder, |
|
filter, |
|
sort, |
|
allowDots, |
|
serializeDate, |
|
formatter, |
|
encodeValuesOnly |
|
) { |
|
var obj = object; |
|
if (typeof filter === 'function') { |
|
obj = filter(prefix, obj); |
|
} else if (obj instanceof Date) { |
|
obj = serializeDate(obj); |
|
} else if (obj === null) { |
|
if (strictNullHandling) { |
|
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder) : prefix; |
|
} |
|
|
|
obj = ''; |
|
} |
|
|
|
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) { |
|
if (encoder) { |
|
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder); |
|
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder))]; |
|
} |
|
return [formatter(prefix) + '=' + formatter(String(obj))]; |
|
} |
|
|
|
var values = []; |
|
|
|
if (typeof obj === 'undefined') { |
|
return values; |
|
} |
|
|
|
var objKeys; |
|
if (Array.isArray(filter)) { |
|
objKeys = filter; |
|
} else { |
|
var keys = Object.keys(obj); |
|
objKeys = sort ? keys.sort(sort) : keys; |
|
} |
|
|
|
for (var i = 0; i < objKeys.length; ++i) { |
|
var key = objKeys[i]; |
|
|
|
if (skipNulls && obj[key] === null) { |
|
continue; |
|
} |
|
|
|
if (Array.isArray(obj)) { |
|
values = values.concat(stringify( |
|
obj[key], |
|
generateArrayPrefix(prefix, key), |
|
generateArrayPrefix, |
|
strictNullHandling, |
|
skipNulls, |
|
encoder, |
|
filter, |
|
sort, |
|
allowDots, |
|
serializeDate, |
|
formatter, |
|
encodeValuesOnly |
|
)); |
|
} else { |
|
values = values.concat(stringify( |
|
obj[key], |
|
prefix + (allowDots ? '.' + key : '[' + key + ']'), |
|
generateArrayPrefix, |
|
strictNullHandling, |
|
skipNulls, |
|
encoder, |
|
filter, |
|
sort, |
|
allowDots, |
|
serializeDate, |
|
formatter, |
|
encodeValuesOnly |
|
)); |
|
} |
|
} |
|
|
|
return values; |
|
}; |
|
|
|
module.exports = function (object, opts) { |
|
var obj = object; |
|
var options = opts ? utils.assign({}, opts) : {}; |
|
|
|
if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { |
|
throw new TypeError('Encoder has to be a function.'); |
|
} |
|
|
|
var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; |
|
var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; |
|
var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; |
|
var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; |
|
var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder; |
|
var sort = typeof options.sort === 'function' ? options.sort : null; |
|
var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots; |
|
var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate; |
|
var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly; |
|
if (typeof options.format === 'undefined') { |
|
options.format = formats['default']; |
|
} else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) { |
|
throw new TypeError('Unknown format option provided.'); |
|
} |
|
var formatter = formats.formatters[options.format]; |
|
var objKeys; |
|
var filter; |
|
|
|
if (typeof options.filter === 'function') { |
|
filter = options.filter; |
|
obj = filter('', obj); |
|
} else if (Array.isArray(options.filter)) { |
|
filter = options.filter; |
|
objKeys = filter; |
|
} |
|
|
|
var keys = []; |
|
|
|
if (typeof obj !== 'object' || obj === null) { |
|
return ''; |
|
} |
|
|
|
var arrayFormat; |
|
if (options.arrayFormat in arrayPrefixGenerators) { |
|
arrayFormat = options.arrayFormat; |
|
} else if ('indices' in options) { |
|
arrayFormat = options.indices ? 'indices' : 'repeat'; |
|
} else { |
|
arrayFormat = 'indices'; |
|
} |
|
|
|
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; |
|
|
|
if (!objKeys) { |
|
objKeys = Object.keys(obj); |
|
} |
|
|
|
if (sort) { |
|
objKeys.sort(sort); |
|
} |
|
|
|
for (var i = 0; i < objKeys.length; ++i) { |
|
var key = objKeys[i]; |
|
|
|
if (skipNulls && obj[key] === null) { |
|
continue; |
|
} |
|
|
|
keys = keys.concat(stringify( |
|
obj[key], |
|
key, |
|
generateArrayPrefix, |
|
strictNullHandling, |
|
skipNulls, |
|
encode ? encoder : null, |
|
filter, |
|
sort, |
|
allowDots, |
|
serializeDate, |
|
formatter, |
|
encodeValuesOnly |
|
)); |
|
} |
|
|
|
var joined = keys.join(delimiter); |
|
var prefix = options.addQueryPrefix === true ? '?' : ''; |
|
|
|
return joined.length > 0 ? prefix + joined : ''; |
|
}; |
|
|
|
|
|
/***/ }), |
|
|
|
/***/ 301: |
|
/***/ (function(module, exports, __webpack_require__) { |
|
|
|
"use strict"; |
|
|
|
|
|
var utils = __webpack_require__(179); |
|
|
|
var has = Object.prototype.hasOwnProperty; |
|
|
|
var defaults = { |
|
allowDots: false, |
|
allowPrototypes: false, |
|
arrayLimit: 20, |
|
decoder: utils.decode, |
|
delimiter: '&', |
|
depth: 5, |
|
parameterLimit: 1000, |
|
plainObjects: false, |
|
strictNullHandling: false |
|
}; |
|
|
|
var parseValues = function parseQueryStringValues(str, options) { |
|
var obj = {}; |
|
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; |
|
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; |
|
var parts = cleanStr.split(options.delimiter, limit); |
|
|
|
for (var i = 0; i < parts.length; ++i) { |
|
var part = parts[i]; |
|
|
|
var bracketEqualsPos = part.indexOf(']='); |
|
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; |
|
|
|
var key, val; |
|
if (pos === -1) { |
|
key = options.decoder(part, defaults.decoder); |
|
val = options.strictNullHandling ? null : ''; |
|
} else { |
|
key = options.decoder(part.slice(0, pos), defaults.decoder); |
|
val = options.decoder(part.slice(pos + 1), defaults.decoder); |
|
} |
|
if (has.call(obj, key)) { |
|
obj[key] = [].concat(obj[key]).concat(val); |
|
} else { |
|
obj[key] = val; |
|
} |
|
} |
|
|
|
return obj; |
|
}; |
|
|
|
var parseObject = function (chain, val, options) { |
|
var leaf = val; |
|
|
|
for (var i = chain.length - 1; i >= 0; --i) { |
|
var obj; |
|
var root = chain[i]; |
|
|
|
if (root === '[]') { |
|
obj = []; |
|
obj = obj.concat(leaf); |
|
} else { |
|
obj = options.plainObjects ? Object.create(null) : {}; |
|
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; |
|
var index = parseInt(cleanRoot, 10); |
|
if ( |
|
!isNaN(index) |
|
&& root !== cleanRoot |
|
&& String(index) === cleanRoot |
|
&& index >= 0 |
|
&& (options.parseArrays && index <= options.arrayLimit) |
|
) { |
|
obj = []; |
|
obj[index] = leaf; |
|
} else { |
|
obj[cleanRoot] = leaf; |
|
} |
|
} |
|
|
|
leaf = obj; |
|
} |
|
|
|
return leaf; |
|
}; |
|
|
|
var parseKeys = function parseQueryStringKeys(givenKey, val, options) { |
|
if (!givenKey) { |
|
return; |
|
} |
|
|
|
// Transform dot notation to bracket notation |
|
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; |
|
|
|
// The regex chunks |
|
|
|
var brackets = /(\[[^[\]]*])/; |
|
var child = /(\[[^[\]]*])/g; |
|
|
|
// Get the parent |
|
|
|
var segment = brackets.exec(key); |
|
var parent = segment ? key.slice(0, segment.index) : key; |
|
|
|
// Stash the parent if it exists |
|
|
|
var keys = []; |
|
if (parent) { |
|
// If we aren't using plain objects, optionally prefix keys |
|
// that would overwrite object prototype properties |
|
if (!options.plainObjects && has.call(Object.prototype, parent)) { |
|
if (!options.allowPrototypes) { |
|
return; |
|
} |
|
} |
|
|
|
keys.push(parent); |
|
} |
|
|
|
// Loop through children appending to the array until we hit depth |
|
|
|
var i = 0; |
|
while ((segment = child.exec(key)) !== null && i < options.depth) { |
|
i += 1; |
|
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { |
|
if (!options.allowPrototypes) { |
|
return; |
|
} |
|
} |
|
keys.push(segment[1]); |
|
} |
|
|
|
// If there's a remainder, just add whatever is left |
|
|
|
if (segment) { |
|
keys.push('[' + key.slice(segment.index) + ']'); |
|
} |
|
|
|
return parseObject(keys, val, options); |
|
}; |
|
|
|
module.exports = function (str, opts) { |
|
var options = opts ? utils.assign({}, opts) : {}; |
|
|
|
if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') { |
|
throw new TypeError('Decoder has to be a function.'); |
|
} |
|
|
|
options.ignoreQueryPrefix = options.ignoreQueryPrefix === true; |
|
options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter; |
|
options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth; |
|
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit; |
|
options.parseArrays = options.parseArrays !== false; |
|
options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder; |
|
options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots; |
|
options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects; |
|
options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes; |
|
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit; |
|
options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; |
|
|
|
if (str === '' || str === null || typeof str === 'undefined') { |
|
return options.plainObjects ? Object.create(null) : {}; |
|
} |
|
|
|
var tempObj = typeof str === 'string' ? parseValues(str, options) : str; |
|
var obj = options.plainObjects ? Object.create(null) : {}; |
|
|
|
// Iterate over the keys and setup the new object |
|
|
|
var keys = Object.keys(tempObj); |
|
for (var i = 0; i < keys.length; ++i) { |
|
var key = keys[i]; |
|
var newObj = parseKeys(key, tempObj[key], options); |
|
obj = utils.merge(obj, newObj, options); |
|
} |
|
|
|
return utils.compact(obj); |
|
}; |
|
|
|
|
|
/***/ }), |
|
|
|
/***/ 76: |
|
/***/ (function(module, exports, __webpack_require__) { |
|
|
|
"use strict"; |
|
|
|
|
|
var stringify = __webpack_require__(300); |
|
var parse = __webpack_require__(301); |
|
var formats = __webpack_require__(180); |
|
|
|
module.exports = { |
|
formats: formats, |
|
parse: parse, |
|
stringify: stringify |
|
}; |
|
|
|
|
|
/***/ }), |
|
|
|
/***/ 8: |
|
/***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
|
|
"use strict"; |
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; }); |
|
/* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15); |
|
|
|
function _objectSpread(target) { |
|
for (var i = 1; i < arguments.length; i++) { |
|
var source = arguments[i] != null ? arguments[i] : {}; |
|
var ownKeys = Object.keys(source); |
|
|
|
if (typeof Object.getOwnPropertySymbols === 'function') { |
|
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { |
|
return Object.getOwnPropertyDescriptor(source, sym).enumerable; |
|
})); |
|
} |
|
|
|
ownKeys.forEach(function (key) { |
|
Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]); |
|
}); |
|
} |
|
|
|
return target; |
|
} |
|
|
|
/***/ }) |
|
|
|
/******/ }); |