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 CHANGED
@@ -7,6 +7,8 @@
7
7
  [![license](https://img.shields.io/github/license/asamuzaK/urlSanitizer)](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
 
@@ -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
- const blob = await fetch(url).then((r) => r.blob());
2136
- const data = await createDataURLFromBlob(blob);
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")) {