contentful 11.2.4 → 11.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1674,7 +1674,7 @@ var contentful = (function (exports) {
1674
1674
  *
1675
1675
  * @param {string} url The base of the url (e.g., http://www.google.com)
1676
1676
  * @param {object} [params] The params to be appended
1677
- * @param {?object} options
1677
+ * @param {?(object|Function)} options
1678
1678
  *
1679
1679
  * @returns {string} The formatted url
1680
1680
  */
@@ -1684,6 +1684,11 @@ var contentful = (function (exports) {
1684
1684
  return url;
1685
1685
  }
1686
1686
  var _encode = options && options.encode || encode$2;
1687
+ if (utils$1$1.isFunction(options)) {
1688
+ options = {
1689
+ serialize: options
1690
+ };
1691
+ }
1687
1692
  var serializeFn = options && options.serialize;
1688
1693
  var serializedParams;
1689
1694
  if (serializeFn) {
@@ -2564,60 +2569,14 @@ var contentful = (function (exports) {
2564
2569
  });
2565
2570
  };
2566
2571
  };
2567
- var isURLSameOrigin = platform.hasStandardBrowserEnv ?
2568
- // Standard browser envs have full support of the APIs needed to test
2569
- // whether the request URL is of the same origin as current location.
2570
- function standardBrowserEnv() {
2571
- var msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
2572
- var urlParsingNode = document.createElement('a');
2573
- var originURL;
2574
-
2575
- /**
2576
- * Parse a URL to discover its components
2577
- *
2578
- * @param {String} url The URL to be parsed
2579
- * @returns {Object}
2580
- */
2581
- function resolveURL(url) {
2582
- var href = url;
2583
- if (msie) {
2584
- // IE needs attribute set twice to normalize properties
2585
- urlParsingNode.setAttribute('href', href);
2586
- href = urlParsingNode.href;
2587
- }
2588
- urlParsingNode.setAttribute('href', href);
2589
-
2590
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
2591
- return {
2592
- href: urlParsingNode.href,
2593
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
2594
- host: urlParsingNode.host,
2595
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
2596
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
2597
- hostname: urlParsingNode.hostname,
2598
- port: urlParsingNode.port,
2599
- pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
2600
- };
2601
- }
2602
- originURL = resolveURL(window.location.href);
2603
-
2604
- /**
2605
- * Determine if a URL shares the same origin as the current location
2606
- *
2607
- * @param {String} requestURL The URL to test
2608
- * @returns {boolean} True if URL shares the same origin, otherwise false
2609
- */
2610
- return function isURLSameOrigin(requestURL) {
2611
- var parsed = utils$1$1.isString(requestURL) ? resolveURL(requestURL) : requestURL;
2612
- return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
2572
+ var isURLSameOrigin = platform.hasStandardBrowserEnv ? function (origin, isMSIE) {
2573
+ return function (url) {
2574
+ url = new URL(url, platform.origin);
2575
+ return origin.protocol === url.protocol && origin.host === url.host && (isMSIE || origin.port === url.port);
2613
2576
  };
2614
- }() :
2615
- // Non standard browser envs (web workers, react-native) lack needed support.
2616
- function nonStandardBrowserEnv() {
2617
- return function isURLSameOrigin() {
2618
- return true;
2619
- };
2620
- }();
2577
+ }(new URL(platform.origin), platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)) : function () {
2578
+ return true;
2579
+ };
2621
2580
  var cookies = platform.hasStandardBrowserEnv ?
2622
2581
  // Standard browser envs support document.cookie
2623
2582
  {
@@ -2705,7 +2664,7 @@ var contentful = (function (exports) {
2705
2664
  // eslint-disable-next-line no-param-reassign
2706
2665
  config2 = config2 || {};
2707
2666
  var config = {};
2708
- function getMergedValue(target, source, caseless) {
2667
+ function getMergedValue(target, source, prop, caseless) {
2709
2668
  if (utils$1$1.isPlainObject(target) && utils$1$1.isPlainObject(source)) {
2710
2669
  return utils$1$1.merge.call({
2711
2670
  caseless: caseless
@@ -2719,11 +2678,11 @@ var contentful = (function (exports) {
2719
2678
  }
2720
2679
 
2721
2680
  // eslint-disable-next-line consistent-return
2722
- function mergeDeepProperties(a, b, caseless) {
2681
+ function mergeDeepProperties(a, b, prop, caseless) {
2723
2682
  if (!utils$1$1.isUndefined(b)) {
2724
- return getMergedValue(a, b, caseless);
2683
+ return getMergedValue(a, b, prop, caseless);
2725
2684
  } else if (!utils$1$1.isUndefined(a)) {
2726
- return getMergedValue(undefined, a, caseless);
2685
+ return getMergedValue(undefined, a, prop, caseless);
2727
2686
  }
2728
2687
  }
2729
2688
 
@@ -2780,8 +2739,8 @@ var contentful = (function (exports) {
2780
2739
  socketPath: defaultToConfig2,
2781
2740
  responseEncoding: defaultToConfig2,
2782
2741
  validateStatus: mergeDirectKeys,
2783
- headers: function headers(a, b) {
2784
- return mergeDeepProperties(headersToObject(a), headersToObject(b), true);
2742
+ headers: function headers(a, b, prop) {
2743
+ return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
2785
2744
  }
2786
2745
  };
2787
2746
  utils$1$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
@@ -3630,7 +3589,7 @@ var contentful = (function (exports) {
3630
3589
  return Promise.reject(reason);
3631
3590
  });
3632
3591
  }
3633
- var VERSION = "1.7.7";
3592
+ var VERSION = "1.7.8";
3634
3593
  var validators$1 = {};
3635
3594
 
3636
3595
  // eslint-disable-next-line func-names
@@ -3668,6 +3627,13 @@ var contentful = (function (exports) {
3668
3627
  return validator ? validator(value, opt, opts) : true;
3669
3628
  };
3670
3629
  };
3630
+ validators$1.spelling = function spelling(correctSpelling) {
3631
+ return function (value, opt) {
3632
+ // eslint-disable-next-line no-console
3633
+ console.warn("".concat(opt, " is likely a misspelling of ").concat(correctSpelling));
3634
+ return true;
3635
+ };
3636
+ };
3671
3637
 
3672
3638
  /**
3673
3639
  * Assert object's properties type
@@ -3749,7 +3715,8 @@ var contentful = (function (exports) {
3749
3715
  _context9.prev = 6;
3750
3716
  _context9.t0 = _context9["catch"](0);
3751
3717
  if (_context9.t0 instanceof Error) {
3752
- Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : dummy = new Error();
3718
+ dummy = {};
3719
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
3753
3720
 
3754
3721
  // slice off the Error: ... line
3755
3722
  stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
@@ -3811,6 +3778,10 @@ var contentful = (function (exports) {
3811
3778
  }, true);
3812
3779
  }
3813
3780
  }
3781
+ validator.assertOptions(config, {
3782
+ baseUrl: validators.spelling('baseURL'),
3783
+ withXsrfToken: validators.spelling('withXSRFToken')
3784
+ }, true);
3814
3785
 
3815
3786
  // Set config.method
3816
3787
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
@@ -9959,7 +9930,7 @@ var contentful = (function (exports) {
9959
9930
  http.defaults.baseURL = getGlobalOptions().environmentBaseUrl;
9960
9931
  }
9961
9932
  return {
9962
- version: "11.2.4",
9933
+ version: "11.2.5",
9963
9934
  getSpace: getSpace,
9964
9935
  getContentType: getContentType,
9965
9936
  getContentTypes: getContentTypes,
@@ -10082,7 +10053,7 @@ var contentful = (function (exports) {
10082
10053
  environment: 'master'
10083
10054
  };
10084
10055
  var config = Object.assign(Object.assign({}, defaultConfig), params);
10085
- var userAgentHeader = getUserAgentHeader("contentful.js/".concat("11.2.4"), config.application, config.integration);
10056
+ var userAgentHeader = getUserAgentHeader("contentful.js/".concat("11.2.5"), config.application, config.integration);
10086
10057
  config.headers = Object.assign(Object.assign({}, config.headers), {
10087
10058
  'Content-Type': 'application/vnd.contentful.delivery.v1+json',
10088
10059
  'X-Contentful-User-Agent': userAgentHeader