@networkteam/zebra-utils
Advanced tools
Comparing version 0.3.0 to 0.4.0
import { ImageLoaderProps } from 'next/image'; | ||
declare const imgProxyLoader: (pathSegment?: string) => ({ src, width, quality }: ImageLoaderProps) => string; | ||
declare const imgProxyLoader: (pathSegment: string | undefined, whitelistedSourceUrls: string[]) => ({ src, width, quality }: ImageLoaderProps) => string; | ||
export default imgProxyLoader; | ||
//# sourceMappingURL=loader.d.ts.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
const imgProxyLoader = (pathSegment = '_image') => ({ | ||
const imgProxyLoader = (pathSegment = '_image', whitelistedSourceUrls) => ({ | ||
src, | ||
@@ -14,3 +14,5 @@ width, | ||
}) => { | ||
if (!src.startsWith('s3://')) return src; | ||
if (!whitelistedSourceUrls.some(url => src.startsWith(url))) { | ||
return src; | ||
} | ||
const encodedUrl = (0, _utils.urlSafeBase64)(src); | ||
@@ -17,0 +19,0 @@ const params = new URLSearchParams(); |
{ | ||
"name": "@networkteam/zebra-utils", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"author": "networkteam GmbH", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -5,6 +5,8 @@ import { urlSafeBase64 } from './utils'; | ||
const imgProxyLoader = | ||
(pathSegment: string = '_image') => | ||
(pathSegment: string = '_image', whitelistedSourceUrls: string[]) => | ||
({ src, width, quality }: ImageLoaderProps) => { | ||
// If the source is not an S3 URL, return the original source | ||
if (!src.startsWith('s3://')) return src; | ||
// if the source url is not whitelisted, return the original src | ||
if (!whitelistedSourceUrls.some((url) => src.startsWith(url))) { | ||
return src; | ||
} | ||
@@ -11,0 +13,0 @@ const encodedUrl = urlSafeBase64(src); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83746
1943