Home / Function/ isRemoteAllowed() — astro Function Reference

isRemoteAllowed() — astro Function Reference

Architecture documentation for the isRemoteAllowed() function in remote.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  7d71a8a1_3fbe_5f98_fd7b_39e56b5f23b0["isRemoteAllowed()"]
  be14f71c_abe1_1789_62c6_249b28c23bcc["remote.ts"]
  7d71a8a1_3fbe_5f98_fd7b_39e56b5f23b0 -->|defined in| be14f71c_abe1_1789_62c6_249b28c23bcc
  61517f52_0061_a7c8_31ee_a33231f85f7a["matchHostname()"]
  7d71a8a1_3fbe_5f98_fd7b_39e56b5f23b0 -->|calls| 61517f52_0061_a7c8_31ee_a33231f85f7a
  2c106453_076d_2939_b71b_64bda08efedf["matchPattern()"]
  7d71a8a1_3fbe_5f98_fd7b_39e56b5f23b0 -->|calls| 2c106453_076d_2939_b71b_64bda08efedf
  style 7d71a8a1_3fbe_5f98_fd7b_39e56b5f23b0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/internal-helpers/src/remote.ts lines 115–140

export function isRemoteAllowed(
	src: string,
	{
		domains,
		remotePatterns,
	}: {
		domains: string[];
		remotePatterns: RemotePattern[];
	},
): boolean {
	if (!URL.canParse(src)) {
		return false;
	}

	const url = new URL(src);

	// Non-http(s) protocols are never allowed
	if (!['http:', 'https:', 'data:'].includes(url.protocol)) {
		return false;
	}

	return (
		domains.some((domain) => matchHostname(url, domain)) ||
		remotePatterns.some((remotePattern) => matchPattern(url, remotePattern))
	);
}

Domain

Subdomains

Frequently Asked Questions

What does isRemoteAllowed() do?
isRemoteAllowed() is a function in the astro codebase, defined in packages/internal-helpers/src/remote.ts.
Where is isRemoteAllowed() defined?
isRemoteAllowed() is defined in packages/internal-helpers/src/remote.ts at line 115.
What does isRemoteAllowed() call?
isRemoteAllowed() calls 2 function(s): matchHostname, matchPattern.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free