@astrojs/cloudflare
Version:
Deploy your site to Cloudflare Workers/Pages
14 lines (13 loc) • 457 B
JavaScript
import { isRemotePath } from "@astrojs/internal-helpers/path";
import { matchHostname, matchPattern } from "@astrojs/internal-helpers/remote";
function isRemoteAllowed(src, {
domains = [],
remotePatterns = []
}) {
if (!isRemotePath(src)) return false;
const url = new URL(src);
return domains.some((domain) => matchHostname(url, domain)) || remotePatterns.some((remotePattern) => matchPattern(url, remotePattern));
}
export {
isRemoteAllowed
};