Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function resourceUrl(href, opts = {}, ...rest) {
let url = veniaResourceUrl(href, opts, ...rest);
try {
url = new window.URL(url);
} catch (e) {
const isImage = opts.type && opts.type.startsWith("image");
const base = isImage
? process.env.REACT_APP_VENIA_BASE_DOMAIN
: window.location.origin;
url = new window.URL(url, base);
}
const params = new URLSearchParams(url.search);
params.append("referrer", window.location.hostname);
url.search = `?${params}`;
return url.href;
}