trousse 2.14.0 → 2.14.1

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.
Files changed (2) hide show
  1. package/dist/urls.js +13 -8
  2. package/package.json +1 -1
package/dist/urls.js CHANGED
@@ -383,19 +383,24 @@ const sameQuerySpellings = [
383
383
  ];
384
384
  const percentEscapeRegex = /%[0-9a-f]{2}/gi;
385
385
  const createUrlSpellings = (url) => {
386
- const spellings = [url, url.replace(percentEscapeRegex, (hex) => hex.toUpperCase())];
386
+ const uppercaseHexUrl = url.replace(percentEscapeRegex, (hex) => hex.toUpperCase());
387
+ let spellings = [.../* @__PURE__ */ new Set([url, uppercaseHexUrl])];
387
388
  const hashIndex = url.indexOf("#");
388
389
  const queryEnd = hashIndex === -1 ? url.length : hashIndex;
389
390
  const queryIndex = url.indexOf("?");
390
- if (queryIndex === -1 || queryIndex > queryEnd) return [...new Set(spellings)];
391
- const head = url.slice(0, queryIndex);
392
- const query = url.slice(queryIndex, queryEnd);
393
- const fragment = url.slice(queryEnd);
391
+ if (queryIndex === -1 || queryIndex > queryEnd) return spellings;
394
392
  for (const [written, encoded] of sameQuerySpellings) {
395
- spellings.push(`${head}${query.replaceAll(written, encoded)}${fragment}`);
396
- spellings.push(`${head}${query.replaceAll(encoded, written)}${fragment}`);
393
+ const swapped = spellings.flatMap((spelling) => {
394
+ const fragmentIndex = spelling.indexOf("#");
395
+ const spellingQueryEnd = fragmentIndex === -1 ? spelling.length : fragmentIndex;
396
+ const head = spelling.slice(0, queryIndex);
397
+ const query = spelling.slice(queryIndex, spellingQueryEnd);
398
+ const fragment = spelling.slice(spellingQueryEnd);
399
+ return [`${head}${query.replaceAll(encoded, written)}${fragment}`, `${head}${query.replaceAll(written, encoded)}${fragment}`];
400
+ });
401
+ spellings = [...new Set(swapped)];
397
402
  }
398
- return [...new Set(spellings)];
403
+ return [.../* @__PURE__ */ new Set([url, ...spellings])];
399
404
  };
400
405
  const genericSecondLevels = [
401
406
  "ac",
package/package.json CHANGED
@@ -46,5 +46,5 @@
46
46
  "dependencies": {
47
47
  "entities": "^8.1.0"
48
48
  },
49
- "version": "2.14.0"
49
+ "version": "2.14.1"
50
50
  }