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.
- package/README.md +2 -2
- package/dist/clean.mjs +13 -18
- package/dist/defaults.mjs +2 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +2 -1
- package/dist/node_modules/trousse/dist/urls.mjs +33 -4
- package/dist/unwraps/aceml.mjs +2 -4
- package/dist/unwraps/adjust.mjs +5 -5
- package/dist/unwraps/amazonSes.mjs +3 -5
- package/dist/unwraps/anchor.mjs +2 -3
- package/dist/unwraps/apptrkr.mjs +3 -3
- package/dist/unwraps/archiveToday.mjs +2 -2
- package/dist/unwraps/augure.mjs +2 -7
- package/dist/unwraps/bing.mjs +2 -2
- package/dist/unwraps/bingAds.mjs +5 -7
- package/dist/unwraps/bitrix.mjs +3 -2
- package/dist/unwraps/ciscoSecureWeb.mjs +4 -7
- package/dist/unwraps/cjNetwork.mjs +2 -8
- package/dist/unwraps/cse360.mjs +4 -7
- package/dist/unwraps/datalifeEngine.mjs +2 -2
- package/dist/unwraps/deployer.mjs +2 -2
- package/dist/unwraps/digikala.mjs +2 -2
- package/dist/unwraps/disqus.mjs +4 -1
- package/dist/unwraps/easyMarketing.mjs +2 -2
- package/dist/unwraps/facebook.mjs +5 -7
- package/dist/unwraps/feedStatistics.mjs +2 -2
- package/dist/unwraps/firebaseDynamicLinks.mjs +1 -1
- package/dist/unwraps/firstory.mjs +2 -4
- package/dist/unwraps/gfnLinkProxy.mjs +2 -2
- package/dist/unwraps/godcaster.mjs +3 -3
- package/dist/unwraps/govdelivery.d.mts +4 -0
- package/dist/unwraps/govdelivery.mjs +12 -0
- package/dist/unwraps/impact.mjs +3 -3
- package/dist/unwraps/indexHu.mjs +3 -3
- package/dist/unwraps/invisionNoExternalLinks.mjs +3 -3
- package/dist/unwraps/linksynergy.mjs +3 -3
- package/dist/unwraps/logicboard.mjs +3 -3
- package/dist/unwraps/mailinblack.mjs +2 -2
- package/dist/unwraps/mandrill.mjs +2 -2
- package/dist/unwraps/mimecast.mjs +1 -4
- package/dist/unwraps/mohtwize.mjs +2 -6
- package/dist/unwraps/mozillaOutgoing.mjs +2 -2
- package/dist/unwraps/newswire.mjs +2 -2
- package/dist/unwraps/postAffiliatePro.mjs +3 -3
- package/dist/unwraps/postmark.mjs +2 -2
- package/dist/unwraps/prezly.mjs +2 -7
- package/dist/unwraps/proofpointV1.mjs +6 -15
- package/dist/unwraps/proofpointV2.mjs +12 -2
- package/dist/unwraps/qualityClick.mjs +3 -3
- package/dist/unwraps/researchgate.mjs +3 -5
- package/dist/unwraps/reviveAdserver.mjs +3 -5
- package/dist/unwraps/serendipity.mjs +2 -2
- package/dist/unwraps/streak.mjs +3 -5
- package/dist/unwraps/surly.mjs +2 -8
- package/dist/unwraps/webArchive.mjs +2 -2
- package/dist/unwraps/xengentr.mjs +2 -2
- package/dist/unwraps/yahooJapanAmpViewer.mjs +2 -7
- package/dist/unwraps/yahooSearch.mjs +3 -2
- package/dist/unwraps/yandexMail.mjs +2 -2
- package/dist/unwraps/yourMembership.mjs +3 -3
- package/dist/utils.mjs +17 -14
- 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
|
|
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
|
|
15
|
+
const separator = pair.indexOf("=");
|
|
16
|
+
const raw = separator === -1 ? "" : pair.slice(separator + 1);
|
|
20
17
|
if (!unencodedTargetRegex.test(raw)) {
|
|
21
|
-
values.push(
|
|
18
|
+
values.push(decodePercent(raw.replaceAll("+", " ")));
|
|
22
19
|
continue;
|
|
23
20
|
}
|
|
24
|
-
values.push(
|
|
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
|
-
|
|
58
|
-
for (let index = 0; index < binary.length; index++)
|
|
59
|
-
|
|
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
|
|
78
|
+
export { createParamExtractor, decodeBase64, decodeBase64Binary, decodeBase64Url, decodeBase64UrlBinary, decodeEncodedScheme, getParamTarget, getParamValues, getUtf8ByteLength };
|