url-sanitizer 0.8.0 → 0.8.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 -0
- package/dist/url-sanitizer.js +6 -2
- package/dist/url-sanitizer.js.map +2 -2
- package/dist/url-sanitizer.min.js +3 -3
- package/dist/url-sanitizer.min.js.map +2 -2
- package/package.json +20 -20
- package/src/mjs/file-reader.js +5 -8
- package/src/mjs/uri-util.js +7 -2
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
[](LICENSE)
|
|
8
8
|
|
|
9
9
|
URL sanitizer for Node.js (>=18), browsers and web sites.
|
|
10
|
+
Sanitize not only regular URLs, but also data URLs and blob URLs.
|
|
11
|
+
Also ability to parse URLs and verify URIs.
|
|
10
12
|
**Experimental**
|
|
11
13
|
|
|
12
14
|
|
package/dist/url-sanitizer.js
CHANGED
|
@@ -2132,8 +2132,12 @@ var sanitizeURL = async (url, opt = {
|
|
|
2132
2132
|
if (protocol === "blob:") {
|
|
2133
2133
|
const { allow, deny, only } = opt;
|
|
2134
2134
|
if (Array.isArray(allow) && allow.includes("blob") && !(Array.isArray(deny) && deny.includes("blob")) || Array.isArray(only) && only.includes("blob")) {
|
|
2135
|
-
|
|
2136
|
-
|
|
2135
|
+
let data;
|
|
2136
|
+
try {
|
|
2137
|
+
data = await fetch(url).then((r) => r.blob()).then(createDataURLFromBlob);
|
|
2138
|
+
URL.revokeObjectURL(url);
|
|
2139
|
+
} catch (e) {
|
|
2140
|
+
}
|
|
2137
2141
|
if (data) {
|
|
2138
2142
|
if (Array.isArray(only)) {
|
|
2139
2143
|
if (!only.includes("data")) {
|