@dereekb/util 11.0.15 → 11.0.17

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.
@@ -4836,19 +4836,76 @@ $$1({ global: true, constructor: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTO
4836
4836
  URL: URLConstructor
4837
4837
  });
4838
4838
 
4839
+ var anObject$1 = anObject$e;
4840
+
4841
+ // `RegExp.prototype.flags` getter implementation
4842
+ // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
4843
+ var regexpFlags = function () {
4844
+ var that = anObject$1(this);
4845
+ var result = '';
4846
+ if (that.hasIndices) result += 'd';
4847
+ if (that.global) result += 'g';
4848
+ if (that.ignoreCase) result += 'i';
4849
+ if (that.multiline) result += 'm';
4850
+ if (that.dotAll) result += 's';
4851
+ if (that.unicode) result += 'u';
4852
+ if (that.unicodeSets) result += 'v';
4853
+ if (that.sticky) result += 'y';
4854
+ return result;
4855
+ };
4856
+
4857
+ var call = functionCall;
4858
+ var hasOwn = hasOwnProperty_1;
4859
+ var isPrototypeOf = objectIsPrototypeOf;
4860
+ var regExpFlags = regexpFlags;
4861
+
4862
+ var RegExpPrototype$1 = RegExp.prototype;
4863
+
4864
+ var regexpGetFlags = function (R) {
4865
+ var flags = R.flags;
4866
+ return flags === undefined && !('flags' in RegExpPrototype$1) && !hasOwn(R, 'flags') && isPrototypeOf(RegExpPrototype$1, R)
4867
+ ? call(regExpFlags, R) : flags;
4868
+ };
4869
+
4870
+ var PROPER_FUNCTION_NAME = functionName.PROPER;
4871
+ var defineBuiltIn$1 = defineBuiltIn$a;
4872
+ var anObject = anObject$e;
4873
+ var $toString = toString$2;
4874
+ var fails$1 = fails$g;
4875
+ var getRegExpFlags = regexpGetFlags;
4876
+
4877
+ var TO_STRING = 'toString';
4878
+ var RegExpPrototype = RegExp.prototype;
4879
+ var nativeToString = RegExpPrototype[TO_STRING];
4880
+
4881
+ var NOT_GENERIC = fails$1(function () { return nativeToString.call({ source: 'a', flags: 'b' }) !== '/a/b'; });
4882
+ // FF44- RegExp#toString has a wrong name
4883
+ var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name !== TO_STRING;
4884
+
4885
+ // `RegExp.prototype.toString` method
4886
+ // https://tc39.es/ecma262/#sec-regexp.prototype.tostring
4887
+ if (NOT_GENERIC || INCORRECT_NAME) {
4888
+ defineBuiltIn$1(RegExpPrototype, TO_STRING, function toString() {
4889
+ var R = anObject(this);
4890
+ var pattern = $toString(R.source);
4891
+ var flags = $toString(getRegExpFlags(R));
4892
+ return '/' + pattern + '/' + flags;
4893
+ }, { unsafe: true });
4894
+ }
4895
+
4839
4896
  var $ = _export;
4840
4897
  var NativePromiseConstructor = promiseNativeConstructor;
4841
- var fails$1 = fails$g;
4898
+ var fails = fails$g;
4842
4899
  var getBuiltIn = getBuiltIn$8;
4843
4900
  var isCallable = isCallable$l;
4844
4901
  var speciesConstructor = speciesConstructor$2;
4845
4902
  var promiseResolve = promiseResolve$2;
4846
- var defineBuiltIn$1 = defineBuiltIn$a;
4903
+ var defineBuiltIn = defineBuiltIn$a;
4847
4904
 
4848
4905
  var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
4849
4906
 
4850
4907
  // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
4851
- var NON_GENERIC = !!NativePromiseConstructor && fails$1(function () {
4908
+ var NON_GENERIC = !!NativePromiseConstructor && fails(function () {
4852
4909
  // eslint-disable-next-line unicorn/no-thenable -- required for testing
4853
4910
  NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
4854
4911
  });
@@ -4874,7 +4931,7 @@ $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
4874
4931
  if (isCallable(NativePromiseConstructor)) {
4875
4932
  var method = getBuiltIn('Promise').prototype['finally'];
4876
4933
  if (NativePromisePrototype['finally'] !== method) {
4877
- defineBuiltIn$1(NativePromisePrototype, 'finally', method, { unsafe: true });
4934
+ defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true });
4878
4935
  }
4879
4936
  }
4880
4937
 
@@ -5065,13 +5122,20 @@ function fetchRequestFactory(config) {
5065
5122
  baseRequest: inputBaseRequest,
5066
5123
  timeout,
5067
5124
  requestInitFactory,
5068
- useBaseUrlForConfiguredFetchRequests = false
5125
+ useBaseUrlForConfiguredFetchRequests = false,
5126
+ forceBaseUrlForWebsiteUrlWithPrefix = useBaseUrlForConfiguredFetchRequests
5069
5127
  } = config;
5070
5128
  const baseUrl = inputBaseUrl ? new URL(util.removeTrailingSlashes(inputBaseUrl)) : undefined;
5071
5129
  const buildUrl = baseUrl ? url => {
5072
- // retain the origin and any pathname from the base url
5073
- const urlPath = baseUrl.origin + util.fixMultiSlashesInSlashPath('/' + baseUrl.pathname + '/' + url);
5074
- const result = new URL(urlPath, baseUrl);
5130
+ let result;
5131
+ const urlString = url.toString();
5132
+ // retain the origin and any pathname from the base url, unless the url contains a prefix
5133
+ if (!forceBaseUrlForWebsiteUrlWithPrefix && util.isWebsiteUrlWithPrefix(urlString)) {
5134
+ result = new URL(urlString);
5135
+ } else {
5136
+ const urlPath = baseUrl.origin + util.fixMultiSlashesInSlashPath('/' + baseUrl.pathname + '/' + url);
5137
+ result = new URL(urlPath, baseUrl);
5138
+ }
5075
5139
  return result;
5076
5140
  } : undefined;
5077
5141
  const buildRequestWithFixedUrl = buildUrl ? _async$3(function (input) {
@@ -5572,63 +5636,6 @@ function makeUrlSearchParams(input, options) {
5572
5636
  return searchParams;
5573
5637
  }
5574
5638
 
5575
- var anObject$1 = anObject$e;
5576
-
5577
- // `RegExp.prototype.flags` getter implementation
5578
- // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
5579
- var regexpFlags = function () {
5580
- var that = anObject$1(this);
5581
- var result = '';
5582
- if (that.hasIndices) result += 'd';
5583
- if (that.global) result += 'g';
5584
- if (that.ignoreCase) result += 'i';
5585
- if (that.multiline) result += 'm';
5586
- if (that.dotAll) result += 's';
5587
- if (that.unicode) result += 'u';
5588
- if (that.unicodeSets) result += 'v';
5589
- if (that.sticky) result += 'y';
5590
- return result;
5591
- };
5592
-
5593
- var call = functionCall;
5594
- var hasOwn = hasOwnProperty_1;
5595
- var isPrototypeOf = objectIsPrototypeOf;
5596
- var regExpFlags = regexpFlags;
5597
-
5598
- var RegExpPrototype$1 = RegExp.prototype;
5599
-
5600
- var regexpGetFlags = function (R) {
5601
- var flags = R.flags;
5602
- return flags === undefined && !('flags' in RegExpPrototype$1) && !hasOwn(R, 'flags') && isPrototypeOf(RegExpPrototype$1, R)
5603
- ? call(regExpFlags, R) : flags;
5604
- };
5605
-
5606
- var PROPER_FUNCTION_NAME = functionName.PROPER;
5607
- var defineBuiltIn = defineBuiltIn$a;
5608
- var anObject = anObject$e;
5609
- var $toString = toString$2;
5610
- var fails = fails$g;
5611
- var getRegExpFlags = regexpGetFlags;
5612
-
5613
- var TO_STRING = 'toString';
5614
- var RegExpPrototype = RegExp.prototype;
5615
- var nativeToString = RegExpPrototype[TO_STRING];
5616
-
5617
- var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) !== '/a/b'; });
5618
- // FF44- RegExp#toString has a wrong name
5619
- var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name !== TO_STRING;
5620
-
5621
- // `RegExp.prototype.toString` method
5622
- // https://tc39.es/ecma262/#sec-regexp.prototype.tostring
5623
- if (NOT_GENERIC || INCORRECT_NAME) {
5624
- defineBuiltIn(RegExpPrototype, TO_STRING, function toString() {
5625
- var R = anObject(this);
5626
- var pattern = $toString(R.source);
5627
- var flags = $toString(getRegExpFlags(R));
5628
- return '/' + pattern + '/' + flags;
5629
- }, { unsafe: true });
5630
- }
5631
-
5632
5639
  function fetchURL(input) {
5633
5640
  let url;
5634
5641
  if (typeof input === 'string') {
@@ -1,4 +1,4 @@
1
- import { removeTrailingSlashes, asGetter, multiValueMapBuilder, filterMaybeValues, objectToTuples, fixMultiSlashesInSlashPath, isPromiseLike, cachedGetter, FIRST_PAGE, performAsyncTasks, mapIdentityFunction, performTasksFromFactoryInParallelFunction, mergeObjects, useIterableOrValue, isEmptyIterable, fixExtraQueryParameters, forEachInIterable, isIterable, forEachKeyValue } from '@dereekb/util';
1
+ import { removeTrailingSlashes, asGetter, multiValueMapBuilder, filterMaybeValues, objectToTuples, isWebsiteUrlWithPrefix, fixMultiSlashesInSlashPath, isPromiseLike, cachedGetter, FIRST_PAGE, performAsyncTasks, mapIdentityFunction, performTasksFromFactoryInParallelFunction, mergeObjects, useIterableOrValue, isEmptyIterable, fixExtraQueryParameters, forEachInIterable, isIterable, forEachKeyValue } from '@dereekb/util';
2
2
 
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
 
@@ -4831,19 +4831,76 @@ $$1({ global: true, constructor: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTO
4831
4831
  URL: URLConstructor
4832
4832
  });
4833
4833
 
4834
+ var anObject$1 = anObject$e;
4835
+
4836
+ // `RegExp.prototype.flags` getter implementation
4837
+ // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
4838
+ var regexpFlags = function () {
4839
+ var that = anObject$1(this);
4840
+ var result = '';
4841
+ if (that.hasIndices) result += 'd';
4842
+ if (that.global) result += 'g';
4843
+ if (that.ignoreCase) result += 'i';
4844
+ if (that.multiline) result += 'm';
4845
+ if (that.dotAll) result += 's';
4846
+ if (that.unicode) result += 'u';
4847
+ if (that.unicodeSets) result += 'v';
4848
+ if (that.sticky) result += 'y';
4849
+ return result;
4850
+ };
4851
+
4852
+ var call = functionCall;
4853
+ var hasOwn = hasOwnProperty_1;
4854
+ var isPrototypeOf = objectIsPrototypeOf;
4855
+ var regExpFlags = regexpFlags;
4856
+
4857
+ var RegExpPrototype$1 = RegExp.prototype;
4858
+
4859
+ var regexpGetFlags = function (R) {
4860
+ var flags = R.flags;
4861
+ return flags === undefined && !('flags' in RegExpPrototype$1) && !hasOwn(R, 'flags') && isPrototypeOf(RegExpPrototype$1, R)
4862
+ ? call(regExpFlags, R) : flags;
4863
+ };
4864
+
4865
+ var PROPER_FUNCTION_NAME = functionName.PROPER;
4866
+ var defineBuiltIn$1 = defineBuiltIn$a;
4867
+ var anObject = anObject$e;
4868
+ var $toString = toString$2;
4869
+ var fails$1 = fails$g;
4870
+ var getRegExpFlags = regexpGetFlags;
4871
+
4872
+ var TO_STRING = 'toString';
4873
+ var RegExpPrototype = RegExp.prototype;
4874
+ var nativeToString = RegExpPrototype[TO_STRING];
4875
+
4876
+ var NOT_GENERIC = fails$1(function () { return nativeToString.call({ source: 'a', flags: 'b' }) !== '/a/b'; });
4877
+ // FF44- RegExp#toString has a wrong name
4878
+ var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name !== TO_STRING;
4879
+
4880
+ // `RegExp.prototype.toString` method
4881
+ // https://tc39.es/ecma262/#sec-regexp.prototype.tostring
4882
+ if (NOT_GENERIC || INCORRECT_NAME) {
4883
+ defineBuiltIn$1(RegExpPrototype, TO_STRING, function toString() {
4884
+ var R = anObject(this);
4885
+ var pattern = $toString(R.source);
4886
+ var flags = $toString(getRegExpFlags(R));
4887
+ return '/' + pattern + '/' + flags;
4888
+ }, { unsafe: true });
4889
+ }
4890
+
4834
4891
  var $ = _export;
4835
4892
  var NativePromiseConstructor = promiseNativeConstructor;
4836
- var fails$1 = fails$g;
4893
+ var fails = fails$g;
4837
4894
  var getBuiltIn = getBuiltIn$8;
4838
4895
  var isCallable = isCallable$l;
4839
4896
  var speciesConstructor = speciesConstructor$2;
4840
4897
  var promiseResolve = promiseResolve$2;
4841
- var defineBuiltIn$1 = defineBuiltIn$a;
4898
+ var defineBuiltIn = defineBuiltIn$a;
4842
4899
 
4843
4900
  var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
4844
4901
 
4845
4902
  // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
4846
- var NON_GENERIC = !!NativePromiseConstructor && fails$1(function () {
4903
+ var NON_GENERIC = !!NativePromiseConstructor && fails(function () {
4847
4904
  // eslint-disable-next-line unicorn/no-thenable -- required for testing
4848
4905
  NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
4849
4906
  });
@@ -4869,7 +4926,7 @@ $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
4869
4926
  if (isCallable(NativePromiseConstructor)) {
4870
4927
  var method = getBuiltIn('Promise').prototype['finally'];
4871
4928
  if (NativePromisePrototype['finally'] !== method) {
4872
- defineBuiltIn$1(NativePromisePrototype, 'finally', method, { unsafe: true });
4929
+ defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true });
4873
4930
  }
4874
4931
  }
4875
4932
 
@@ -5009,13 +5066,21 @@ function fetchRequestFactory(config) {
5009
5066
  baseRequest: inputBaseRequest,
5010
5067
  timeout,
5011
5068
  requestInitFactory,
5012
- useBaseUrlForConfiguredFetchRequests = false
5069
+ useBaseUrlForConfiguredFetchRequests = false,
5070
+ forceBaseUrlForWebsiteUrlWithPrefix = useBaseUrlForConfiguredFetchRequests
5013
5071
  } = config;
5014
5072
  const baseUrl = inputBaseUrl ? new URL(removeTrailingSlashes(inputBaseUrl)) : undefined;
5015
5073
  const buildUrl = baseUrl ? url => {
5016
- // retain the origin and any pathname from the base url
5017
- const urlPath = baseUrl.origin + fixMultiSlashesInSlashPath('/' + baseUrl.pathname + '/' + url);
5018
- const result = new URL(urlPath, baseUrl);
5074
+ let result;
5075
+ const urlString = url.toString();
5076
+
5077
+ // retain the origin and any pathname from the base url, unless the url contains a prefix
5078
+ if (!forceBaseUrlForWebsiteUrlWithPrefix && isWebsiteUrlWithPrefix(urlString)) {
5079
+ result = new URL(urlString);
5080
+ } else {
5081
+ const urlPath = baseUrl.origin + fixMultiSlashesInSlashPath('/' + baseUrl.pathname + '/' + url);
5082
+ result = new URL(urlPath, baseUrl);
5083
+ }
5019
5084
  return result;
5020
5085
  } : undefined;
5021
5086
  async function asFetchRequest(input) {
@@ -5450,63 +5515,6 @@ function makeUrlSearchParams(input, options) {
5450
5515
  return searchParams;
5451
5516
  }
5452
5517
 
5453
- var anObject$1 = anObject$e;
5454
-
5455
- // `RegExp.prototype.flags` getter implementation
5456
- // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
5457
- var regexpFlags = function () {
5458
- var that = anObject$1(this);
5459
- var result = '';
5460
- if (that.hasIndices) result += 'd';
5461
- if (that.global) result += 'g';
5462
- if (that.ignoreCase) result += 'i';
5463
- if (that.multiline) result += 'm';
5464
- if (that.dotAll) result += 's';
5465
- if (that.unicode) result += 'u';
5466
- if (that.unicodeSets) result += 'v';
5467
- if (that.sticky) result += 'y';
5468
- return result;
5469
- };
5470
-
5471
- var call = functionCall;
5472
- var hasOwn = hasOwnProperty_1;
5473
- var isPrototypeOf = objectIsPrototypeOf;
5474
- var regExpFlags = regexpFlags;
5475
-
5476
- var RegExpPrototype$1 = RegExp.prototype;
5477
-
5478
- var regexpGetFlags = function (R) {
5479
- var flags = R.flags;
5480
- return flags === undefined && !('flags' in RegExpPrototype$1) && !hasOwn(R, 'flags') && isPrototypeOf(RegExpPrototype$1, R)
5481
- ? call(regExpFlags, R) : flags;
5482
- };
5483
-
5484
- var PROPER_FUNCTION_NAME = functionName.PROPER;
5485
- var defineBuiltIn = defineBuiltIn$a;
5486
- var anObject = anObject$e;
5487
- var $toString = toString$2;
5488
- var fails = fails$g;
5489
- var getRegExpFlags = regexpGetFlags;
5490
-
5491
- var TO_STRING = 'toString';
5492
- var RegExpPrototype = RegExp.prototype;
5493
- var nativeToString = RegExpPrototype[TO_STRING];
5494
-
5495
- var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) !== '/a/b'; });
5496
- // FF44- RegExp#toString has a wrong name
5497
- var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name !== TO_STRING;
5498
-
5499
- // `RegExp.prototype.toString` method
5500
- // https://tc39.es/ecma262/#sec-regexp.prototype.tostring
5501
- if (NOT_GENERIC || INCORRECT_NAME) {
5502
- defineBuiltIn(RegExpPrototype, TO_STRING, function toString() {
5503
- var R = anObject(this);
5504
- var pattern = $toString(R.source);
5505
- var flags = $toString(getRegExpFlags(R));
5506
- return '/' + pattern + '/' + flags;
5507
- }, { unsafe: true });
5508
- }
5509
-
5510
5518
  function fetchURL(input) {
5511
5519
  let url;
5512
5520
  if (typeof input === 'string') {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util/fetch",
3
- "version": "11.0.15",
3
+ "version": "11.0.17",
4
4
  ".": {
5
5
  "types": "./src/index.d.ts",
6
6
  "node": {
@@ -76,6 +76,12 @@ export interface FetchRequestFactoryInput {
76
76
  * Whether or not to append the base url to RequestInfo that is already configured, instead of only URL or strings.
77
77
  */
78
78
  useBaseUrlForConfiguredFetchRequests?: boolean;
79
+ /**
80
+ * Whether or not to force always using the base url even when a WebsiteUrlWithPrefix value is provided.
81
+ *
82
+ * Defaults to useBaseUrlForConfiguredFetchRequests's value.
83
+ */
84
+ forceBaseUrlForWebsiteUrlWithPrefix?: boolean;
79
85
  /**
80
86
  * Base request info to add to each value.
81
87
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util",
3
- "version": "11.0.15",
3
+ "version": "11.0.17",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
package/test/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [11.0.17](https://github.com/dereekb/dbx-components/compare/v11.0.16-dev...v11.0.17) (2024-12-05)
6
+
7
+
8
+
9
+ ## [11.0.16](https://github.com/dereekb/dbx-components/compare/v11.0.15-dev...v11.0.16) (2024-12-05)
10
+
11
+
12
+
5
13
  ## [11.0.15](https://github.com/dereekb/dbx-components/compare/v11.0.14-dev...v11.0.15) (2024-11-29)
6
14
 
7
15
 
package/test/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util/test",
3
- "version": "11.0.15",
3
+ "version": "11.0.17",
4
4
  "type": "commonjs",
5
5
  "peerDependencies": {
6
6
  "@dereekb/util": "*"