@uniformdev/redirect 19.118.1-alpha.0 → 19.118.1-alpha.10

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.
package/dist/index.d.mts CHANGED
@@ -111,7 +111,6 @@ declare class RedirectClient extends ApiClient<RedirectClientOptions> {
111
111
  */
112
112
  private static processDefinitionToResults;
113
113
  static validateRedirect(url: string, redirectDefinition: RedirectDefinition['redirect']): boolean;
114
- private static getSourceVariables;
115
114
  }
116
115
  declare class UncachedRedirectClient extends RedirectClient {
117
116
  constructor(options: Omit<RedirectClientOptions, 'bypassCache'>);
package/dist/index.d.ts CHANGED
@@ -111,7 +111,6 @@ declare class RedirectClient extends ApiClient<RedirectClientOptions> {
111
111
  */
112
112
  private static processDefinitionToResults;
113
113
  static validateRedirect(url: string, redirectDefinition: RedirectDefinition['redirect']): boolean;
114
- private static getSourceVariables;
115
114
  }
116
115
  declare class UncachedRedirectClient extends RedirectClient {
117
116
  constructor(options: Omit<RedirectClientOptions, 'bypassCache'>);
package/dist/index.esm.js CHANGED
@@ -302,11 +302,8 @@ function getSourceVariables(path, source, isVariable = (pathSegment, isLast) =>
302
302
  const variables = {};
303
303
  const pathSegments = path.split("/");
304
304
  const sourceSegments = source.split("/");
305
- if (pathSegments.length !== sourceSegments.length && !source.endsWith("/*")) {
306
- throw new Error("Path and source have different numbers of path segments, must be the same");
307
- }
308
305
  sourceSegments.forEach((sourceSegment, i) => {
309
- if (isVariable(sourceSegment, i === sourceSegments.length - 1)) {
306
+ if (pathSegments.length >= i && isVariable(sourceSegment, i === sourceSegments.length - 1)) {
310
307
  variables[sourceSegment] = pathSegments[i];
311
308
  }
312
309
  });
@@ -431,7 +428,7 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
431
428
  return _RedirectClient.processDefinitionToResults(
432
429
  processedUrl,
433
430
  redirect,
434
- _RedirectClient.getSourceVariables(
431
+ getSourceVariables(
435
432
  processedUrl.path,
436
433
  processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
437
434
  ),
@@ -454,7 +451,7 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
454
451
  return _RedirectClient.processDefinitionToResults(
455
452
  processedUrl,
456
453
  redirect,
457
- _RedirectClient.getSourceVariables(
454
+ getSourceVariables(
458
455
  processedUrl.path,
459
456
  processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
460
457
  ),
@@ -620,20 +617,6 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
620
617
  }
621
618
  return true;
622
619
  }
623
- static getSourceVariables(path, source, isVariable = (pathSegment, isLast) => pathSegment.startsWith(":") || pathSegment === "*" && isLast) {
624
- const variables = {};
625
- const pathSegments = path.split("/");
626
- const sourceSegments = source.split("/");
627
- if (pathSegments.length !== sourceSegments.length && !source.endsWith("/*")) {
628
- throw new Error("Path and source have different numbers of path segments, must be the same");
629
- }
630
- sourceSegments.forEach((sourceSegment, i) => {
631
- if (isVariable(sourceSegment, i === sourceSegments.length - 1)) {
632
- variables[sourceSegment] = pathSegments[i];
633
- }
634
- });
635
- return variables;
636
- }
637
620
  };
638
621
  _RedirectClient.processUrlBestMatch = async (url, trie, options) => {
639
622
  var _a;
package/dist/index.js CHANGED
@@ -348,11 +348,8 @@ function getSourceVariables(path, source, isVariable = (pathSegment, isLast) =>
348
348
  const variables = {};
349
349
  const pathSegments = path.split("/");
350
350
  const sourceSegments = source.split("/");
351
- if (pathSegments.length !== sourceSegments.length && !source.endsWith("/*")) {
352
- throw new Error("Path and source have different numbers of path segments, must be the same");
353
- }
354
351
  sourceSegments.forEach((sourceSegment, i) => {
355
- if (isVariable(sourceSegment, i === sourceSegments.length - 1)) {
352
+ if (pathSegments.length >= i && isVariable(sourceSegment, i === sourceSegments.length - 1)) {
356
353
  variables[sourceSegment] = pathSegments[i];
357
354
  }
358
355
  });
@@ -477,7 +474,7 @@ var _RedirectClient = class _RedirectClient extends import_api.ApiClient {
477
474
  return _RedirectClient.processDefinitionToResults(
478
475
  processedUrl,
479
476
  redirect,
480
- _RedirectClient.getSourceVariables(
477
+ getSourceVariables(
481
478
  processedUrl.path,
482
479
  processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
483
480
  ),
@@ -500,7 +497,7 @@ var _RedirectClient = class _RedirectClient extends import_api.ApiClient {
500
497
  return _RedirectClient.processDefinitionToResults(
501
498
  processedUrl,
502
499
  redirect,
503
- _RedirectClient.getSourceVariables(
500
+ getSourceVariables(
504
501
  processedUrl.path,
505
502
  processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
506
503
  ),
@@ -666,20 +663,6 @@ var _RedirectClient = class _RedirectClient extends import_api.ApiClient {
666
663
  }
667
664
  return true;
668
665
  }
669
- static getSourceVariables(path, source, isVariable = (pathSegment, isLast) => pathSegment.startsWith(":") || pathSegment === "*" && isLast) {
670
- const variables = {};
671
- const pathSegments = path.split("/");
672
- const sourceSegments = source.split("/");
673
- if (pathSegments.length !== sourceSegments.length && !source.endsWith("/*")) {
674
- throw new Error("Path and source have different numbers of path segments, must be the same");
675
- }
676
- sourceSegments.forEach((sourceSegment, i) => {
677
- if (isVariable(sourceSegment, i === sourceSegments.length - 1)) {
678
- variables[sourceSegment] = pathSegments[i];
679
- }
680
- });
681
- return variables;
682
- }
683
666
  };
684
667
  _RedirectClient.processUrlBestMatch = async (url, trie, options) => {
685
668
  var _a;
package/dist/index.mjs CHANGED
@@ -302,11 +302,8 @@ function getSourceVariables(path, source, isVariable = (pathSegment, isLast) =>
302
302
  const variables = {};
303
303
  const pathSegments = path.split("/");
304
304
  const sourceSegments = source.split("/");
305
- if (pathSegments.length !== sourceSegments.length && !source.endsWith("/*")) {
306
- throw new Error("Path and source have different numbers of path segments, must be the same");
307
- }
308
305
  sourceSegments.forEach((sourceSegment, i) => {
309
- if (isVariable(sourceSegment, i === sourceSegments.length - 1)) {
306
+ if (pathSegments.length >= i && isVariable(sourceSegment, i === sourceSegments.length - 1)) {
310
307
  variables[sourceSegment] = pathSegments[i];
311
308
  }
312
309
  });
@@ -431,7 +428,7 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
431
428
  return _RedirectClient.processDefinitionToResults(
432
429
  processedUrl,
433
430
  redirect,
434
- _RedirectClient.getSourceVariables(
431
+ getSourceVariables(
435
432
  processedUrl.path,
436
433
  processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
437
434
  ),
@@ -454,7 +451,7 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
454
451
  return _RedirectClient.processDefinitionToResults(
455
452
  processedUrl,
456
453
  redirect,
457
- _RedirectClient.getSourceVariables(
454
+ getSourceVariables(
458
455
  processedUrl.path,
459
456
  processUrl((options == null ? void 0 : options.reverse) ? redirect.redirect.targetUrl : redirect.redirect.sourceUrl).path
460
457
  ),
@@ -620,20 +617,6 @@ var _RedirectClient = class _RedirectClient extends ApiClient {
620
617
  }
621
618
  return true;
622
619
  }
623
- static getSourceVariables(path, source, isVariable = (pathSegment, isLast) => pathSegment.startsWith(":") || pathSegment === "*" && isLast) {
624
- const variables = {};
625
- const pathSegments = path.split("/");
626
- const sourceSegments = source.split("/");
627
- if (pathSegments.length !== sourceSegments.length && !source.endsWith("/*")) {
628
- throw new Error("Path and source have different numbers of path segments, must be the same");
629
- }
630
- sourceSegments.forEach((sourceSegment, i) => {
631
- if (isVariable(sourceSegment, i === sourceSegments.length - 1)) {
632
- variables[sourceSegment] = pathSegments[i];
633
- }
634
- });
635
- return variables;
636
- }
637
620
  };
638
621
  _RedirectClient.processUrlBestMatch = async (url, trie, options) => {
639
622
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/redirect",
3
- "version": "19.118.1-alpha.0+cf7370c980",
3
+ "version": "19.118.1-alpha.10+578491e54b",
4
4
  "description": "Uniform redirect client",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -33,12 +33,12 @@
33
33
  "/dist"
34
34
  ],
35
35
  "dependencies": {
36
- "@uniformdev/context": "19.118.1-alpha.0+cf7370c980",
36
+ "@uniformdev/context": "19.118.1-alpha.10+578491e54b",
37
37
  "p-limit": "^3.1.0",
38
38
  "rfdc": "^1.3.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "cf7370c9807feb6b6a19764c8c3c82c62eaa8315"
43
+ "gitHead": "578491e54b389231b3508d7ff92507d9f71d4c60"
44
44
  }