trousse 2.14.0 → 2.14.2
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/urls.js +20 -8
- package/package.json +1 -1
package/dist/urls.js
CHANGED
|
@@ -382,20 +382,32 @@ const sameQuerySpellings = [
|
|
|
382
382
|
["@", "%40"]
|
|
383
383
|
];
|
|
384
384
|
const percentEscapeRegex = /%[0-9a-f]{2}/gi;
|
|
385
|
+
const addLowercaseHexSpellings = (url, spellings) => {
|
|
386
|
+
if (url.search(percentEscapeRegex) === -1) return [...new Set(spellings)];
|
|
387
|
+
const lowercaseHexSpellings = spellings.map((spelling) => {
|
|
388
|
+
return spelling.replace(percentEscapeRegex, (hex) => hex.toLowerCase());
|
|
389
|
+
});
|
|
390
|
+
return [.../* @__PURE__ */ new Set([...spellings, ...lowercaseHexSpellings])];
|
|
391
|
+
};
|
|
385
392
|
const createUrlSpellings = (url) => {
|
|
386
|
-
const
|
|
393
|
+
const uppercaseHexUrl = url.replace(percentEscapeRegex, (hex) => hex.toUpperCase());
|
|
394
|
+
let spellings = [.../* @__PURE__ */ new Set([url, uppercaseHexUrl])];
|
|
387
395
|
const hashIndex = url.indexOf("#");
|
|
388
396
|
const queryEnd = hashIndex === -1 ? url.length : hashIndex;
|
|
389
397
|
const queryIndex = url.indexOf("?");
|
|
390
|
-
if (queryIndex === -1 || queryIndex > queryEnd) return
|
|
391
|
-
const head = url.slice(0, queryIndex);
|
|
392
|
-
const query = url.slice(queryIndex, queryEnd);
|
|
393
|
-
const fragment = url.slice(queryEnd);
|
|
398
|
+
if (queryIndex === -1 || queryIndex > queryEnd) return addLowercaseHexSpellings(url, spellings);
|
|
394
399
|
for (const [written, encoded] of sameQuerySpellings) {
|
|
395
|
-
spellings.
|
|
396
|
-
|
|
400
|
+
const swapped = spellings.flatMap((spelling) => {
|
|
401
|
+
const fragmentIndex = spelling.indexOf("#");
|
|
402
|
+
const spellingQueryEnd = fragmentIndex === -1 ? spelling.length : fragmentIndex;
|
|
403
|
+
const head = spelling.slice(0, queryIndex);
|
|
404
|
+
const query = spelling.slice(queryIndex, spellingQueryEnd);
|
|
405
|
+
const fragment = spelling.slice(spellingQueryEnd);
|
|
406
|
+
return [`${head}${query.replaceAll(encoded, written)}${fragment}`, `${head}${query.replaceAll(written, encoded)}${fragment}`];
|
|
407
|
+
});
|
|
408
|
+
spellings = [...new Set(swapped)];
|
|
397
409
|
}
|
|
398
|
-
return [...
|
|
410
|
+
return addLowercaseHexSpellings(url, [url, ...spellings]);
|
|
399
411
|
};
|
|
400
412
|
const genericSecondLevels = [
|
|
401
413
|
"ac",
|
package/package.json
CHANGED