urlpurify 2.0.0 → 2.1.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 (62) hide show
  1. package/README.md +2 -2
  2. package/dist/clean.mjs +13 -18
  3. package/dist/defaults.mjs +2 -0
  4. package/dist/index.d.mts +2 -1
  5. package/dist/index.mjs +2 -1
  6. package/dist/node_modules/trousse/dist/urls.mjs +33 -4
  7. package/dist/unwraps/aceml.mjs +2 -4
  8. package/dist/unwraps/adjust.mjs +5 -5
  9. package/dist/unwraps/amazonSes.mjs +3 -5
  10. package/dist/unwraps/anchor.mjs +2 -3
  11. package/dist/unwraps/apptrkr.mjs +3 -3
  12. package/dist/unwraps/archiveToday.mjs +2 -2
  13. package/dist/unwraps/augure.mjs +2 -7
  14. package/dist/unwraps/bing.mjs +2 -2
  15. package/dist/unwraps/bingAds.mjs +5 -7
  16. package/dist/unwraps/bitrix.mjs +3 -2
  17. package/dist/unwraps/ciscoSecureWeb.mjs +4 -7
  18. package/dist/unwraps/cjNetwork.mjs +2 -8
  19. package/dist/unwraps/cse360.mjs +4 -7
  20. package/dist/unwraps/datalifeEngine.mjs +2 -2
  21. package/dist/unwraps/deployer.mjs +2 -2
  22. package/dist/unwraps/digikala.mjs +2 -2
  23. package/dist/unwraps/disqus.mjs +4 -1
  24. package/dist/unwraps/easyMarketing.mjs +2 -2
  25. package/dist/unwraps/facebook.mjs +5 -7
  26. package/dist/unwraps/feedStatistics.mjs +2 -2
  27. package/dist/unwraps/firebaseDynamicLinks.mjs +1 -1
  28. package/dist/unwraps/firstory.mjs +2 -4
  29. package/dist/unwraps/gfnLinkProxy.mjs +2 -2
  30. package/dist/unwraps/godcaster.mjs +3 -3
  31. package/dist/unwraps/govdelivery.d.mts +4 -0
  32. package/dist/unwraps/govdelivery.mjs +12 -0
  33. package/dist/unwraps/impact.mjs +3 -3
  34. package/dist/unwraps/indexHu.mjs +3 -3
  35. package/dist/unwraps/invisionNoExternalLinks.mjs +3 -3
  36. package/dist/unwraps/linksynergy.mjs +3 -3
  37. package/dist/unwraps/logicboard.mjs +3 -3
  38. package/dist/unwraps/mailinblack.mjs +2 -2
  39. package/dist/unwraps/mandrill.mjs +2 -2
  40. package/dist/unwraps/mimecast.mjs +1 -4
  41. package/dist/unwraps/mohtwize.mjs +2 -6
  42. package/dist/unwraps/mozillaOutgoing.mjs +2 -2
  43. package/dist/unwraps/newswire.mjs +2 -2
  44. package/dist/unwraps/postAffiliatePro.mjs +3 -3
  45. package/dist/unwraps/postmark.mjs +2 -2
  46. package/dist/unwraps/prezly.mjs +2 -7
  47. package/dist/unwraps/proofpointV1.mjs +6 -15
  48. package/dist/unwraps/proofpointV2.mjs +12 -2
  49. package/dist/unwraps/qualityClick.mjs +3 -3
  50. package/dist/unwraps/researchgate.mjs +3 -5
  51. package/dist/unwraps/reviveAdserver.mjs +3 -5
  52. package/dist/unwraps/serendipity.mjs +2 -2
  53. package/dist/unwraps/streak.mjs +3 -5
  54. package/dist/unwraps/surly.mjs +2 -8
  55. package/dist/unwraps/webArchive.mjs +2 -2
  56. package/dist/unwraps/xengentr.mjs +2 -2
  57. package/dist/unwraps/yahooJapanAmpViewer.mjs +2 -7
  58. package/dist/unwraps/yahooSearch.mjs +3 -2
  59. package/dist/unwraps/yandexMail.mjs +2 -2
  60. package/dist/unwraps/yourMembership.mjs +3 -3
  61. package/dist/utils.mjs +17 -14
  62. package/package.json +2 -2
package/dist/utils.mjs CHANGED
@@ -1,14 +1,10 @@
1
1
  import { isAnyOf } from "./node_modules/trousse/dist/matching.mjs";
2
- import { isHostOf, isHostOrSubdomainOf } from "./node_modules/trousse/dist/urls.mjs";
2
+ import { decodePercent, isHostOf, isHostOrSubdomainOf } from "./node_modules/trousse/dist/urls.mjs";
3
3
  //#region src/utils.ts
4
- const percentDecode = (value) => {
5
- const escaped = value.replaceAll("+", "%2B").replaceAll("&", "%26");
6
- return new URLSearchParams(`value=${escaped}`).get("value") ?? "";
7
- };
8
4
  const encodedSchemeRegex = /^https?%3A/i;
9
5
  const decodeEncodedScheme = (value) => {
10
6
  if (!encodedSchemeRegex.test(value)) return value;
11
- return percentDecode(value);
7
+ return decodePercent(value);
12
8
  };
13
9
  const unencodedTargetRegex = /^https?:\/\//i;
14
10
  const getParamValues = (url, name) => {
@@ -16,12 +12,13 @@ const getParamValues = (url, name) => {
16
12
  for (const pair of url.search.slice(1).split("&")) {
17
13
  const entry = new URLSearchParams(`&${pair}`).entries().next().value;
18
14
  if (!entry || entry[0] !== name) continue;
19
- const raw = pair.slice(pair.indexOf("=") + 1);
15
+ const separator = pair.indexOf("=");
16
+ const raw = separator === -1 ? "" : pair.slice(separator + 1);
20
17
  if (!unencodedTargetRegex.test(raw)) {
21
- values.push(entry[1]);
18
+ values.push(decodePercent(raw.replaceAll("+", " ")));
22
19
  continue;
23
20
  }
24
- values.push(percentDecode(raw));
21
+ values.push(decodePercent(raw));
25
22
  }
26
23
  return values;
27
24
  };
@@ -50,13 +47,19 @@ const decodeBase64Binary = (value) => {
50
47
  return atob(value);
51
48
  } catch {}
52
49
  };
53
- const utf8Decoder = new TextDecoder();
54
50
  const decodeBase64 = (value) => {
55
51
  const binary = decodeBase64Binary(value);
56
52
  if (binary === void 0) return;
57
- const bytes = new Uint8Array(binary.length);
58
- for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index);
59
- return utf8Decoder.decode(bytes);
53
+ let encoded = "";
54
+ for (let index = 0; index < binary.length; index++) {
55
+ const byte = binary.charCodeAt(index);
56
+ if (byte < 128 && binary[index] !== "%") {
57
+ encoded += binary[index];
58
+ continue;
59
+ }
60
+ encoded += `%${byte.toString(16).toUpperCase().padStart(2, "0")}`;
61
+ }
62
+ return decodePercent(encoded);
60
63
  };
61
64
  const toBase64 = (base64Url) => {
62
65
  return base64Url.replace(/-/g, "+").replace(/_/g, "/");
@@ -72,4 +75,4 @@ const getUtf8ByteLength = (value) => {
72
75
  return utf8Encoder.encode(value).length;
73
76
  };
74
77
  //#endregion
75
- export { createParamExtractor, decodeBase64, decodeBase64Binary, decodeBase64Url, decodeBase64UrlBinary, getParamTarget, getParamValues, getUtf8ByteLength, percentDecode };
78
+ export { createParamExtractor, decodeBase64, decodeBase64Binary, decodeBase64Url, decodeBase64UrlBinary, decodeEncodedScheme, getParamTarget, getParamValues, getUtf8ByteLength };
package/package.json CHANGED
@@ -42,8 +42,8 @@
42
42
  "devDependencies": {
43
43
  "@types/bun": "^1.4.2",
44
44
  "kvalita": "^1.24.3",
45
- "trousse": "^2.10.1",
45
+ "trousse": "^2.15.0",
46
46
  "tsdown": "^0.23.0"
47
47
  },
48
- "version": "2.0.0"
48
+ "version": "2.1.1"
49
49
  }