@alpaca-headless/alpaca-headless-nextjs 1.0.3213 → 1.0.3215
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.
|
@@ -35,7 +35,10 @@ const protectedParams = [
|
|
|
35
35
|
function hashImageUrl(url) {
|
|
36
36
|
if (!process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET)
|
|
37
37
|
return url;
|
|
38
|
-
|
|
38
|
+
if (!url)
|
|
39
|
+
return url;
|
|
40
|
+
const baseURL = 'http://temp-base-url.com'; // This will serve as a placeholder.
|
|
41
|
+
const uri = new URL(url.toLowerCase(), baseURL);
|
|
39
42
|
uri.searchParams.delete("hash");
|
|
40
43
|
const searchParams = protectedParams
|
|
41
44
|
.map((x) => ({ name: x, val: uri.searchParams.get(x) }))
|
|
@@ -48,6 +51,6 @@ function hashImageUrl(url) {
|
|
|
48
51
|
.update(stringToProtect + process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET, "utf16le")
|
|
49
52
|
.digest("hex");
|
|
50
53
|
uri.searchParams.set("hash", hash);
|
|
51
|
-
return uri.toString();
|
|
54
|
+
return url.startsWith('http') ? uri.toString() : uri.pathname + uri.search;
|
|
52
55
|
}
|
|
53
56
|
exports.hashImageUrl = hashImageUrl;
|
|
@@ -29,7 +29,10 @@ const protectedParams = [
|
|
|
29
29
|
export function hashImageUrl(url) {
|
|
30
30
|
if (!process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET)
|
|
31
31
|
return url;
|
|
32
|
-
|
|
32
|
+
if (!url)
|
|
33
|
+
return url;
|
|
34
|
+
const baseURL = 'http://temp-base-url.com'; // This will serve as a placeholder.
|
|
35
|
+
const uri = new URL(url.toLowerCase(), baseURL);
|
|
33
36
|
uri.searchParams.delete("hash");
|
|
34
37
|
const searchParams = protectedParams
|
|
35
38
|
.map((x) => ({ name: x, val: uri.searchParams.get(x) }))
|
|
@@ -42,5 +45,5 @@ export function hashImageUrl(url) {
|
|
|
42
45
|
.update(stringToProtect + process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET, "utf16le")
|
|
43
46
|
.digest("hex");
|
|
44
47
|
uri.searchParams.set("hash", hash);
|
|
45
|
-
return uri.toString();
|
|
48
|
+
return url.startsWith('http') ? uri.toString() : uri.pathname + uri.search;
|
|
46
49
|
}
|