Home / File/ remote-pattern.test.js — astro Source File

remote-pattern.test.js — astro Source File

Architecture documentation for remote-pattern.test.js, a javascript file in the astro codebase. 3 imports, 0 dependents.

File javascript 3 imports

Entity Profile

Dependency Diagram

graph LR
  20c5083b_be7e_4611_4ea4_75307db72388["remote-pattern.test.js"]
  0e588d0c_5409_f008_bf3b_3762dd6c1c5a["strict"]
  20c5083b_be7e_4611_4ea4_75307db72388 --> 0e588d0c_5409_f008_bf3b_3762dd6c1c5a
  fa887d9d_247c_d770_d661_490745669024["node:test"]
  20c5083b_be7e_4611_4ea4_75307db72388 --> fa887d9d_247c_d770_d661_490745669024
  3bc6e898_80ea_c7ef_a149_44226feb46ff["remote"]
  20c5083b_be7e_4611_4ea4_75307db72388 --> 3bc6e898_80ea_c7ef_a149_44226feb46ff
  style 20c5083b_be7e_4611_4ea4_75307db72388 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import {
	isRemoteAllowed,
	matchHostname,
	matchPathname,
	matchPattern,
	matchPort,
	matchProtocol,
} from '@astrojs/internal-helpers/remote';

describe('remote-pattern', () => {
	const url1 = new URL('https://docs.astro.build/en/getting-started');
	const url2 = new URL('http://preview.docs.astro.build:8080/');
	const url3 = new URL('https://astro.build/');
	const url4 = new URL('https://example.co/');
	const url5 = new URL('data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==');

	describe('remote pattern matchers', () => {
		it('matches protocol', async () => {
			// undefined
			assert.equal(matchProtocol(url1), true);

			// defined, true/false
			assert.equal(matchProtocol(url1, 'http'), false);
			assert.equal(matchProtocol(url1, 'https'), true);
			assert.equal(matchProtocol(url5, 'data'), true);
		});

		it('matches port', async () => {
			// undefined
			assert.equal(matchPort(url1), true);

			// defined, but port is empty (default port used in URL)
			assert.equal(matchPort(url1, ''), true);

			// defined and port is custom
			assert.equal(matchPort(url2, '8080'), true);
		});

		it('matches hostname (no wildcards)', async () => {
			// undefined
			assert.equal(matchHostname(url1), true);

			// defined, true/false
			assert.equal(matchHostname(url1, 'astro.build'), false);
			assert.equal(matchHostname(url1, 'docs.astro.build'), true);
		});

		it('matches hostname (with wildcards)', async () => {
			// defined, true/false
			assert.equal(matchHostname(url1, 'docs.astro.build', true), true);
			assert.equal(matchHostname(url1, '**.astro.build', true), true);
			assert.equal(matchHostname(url1, '*.astro.build', true), true);

			assert.equal(matchHostname(url2, '*.astro.build', true), false);
			assert.equal(matchHostname(url2, '**.astro.build', true), true);

			assert.equal(matchHostname(url3, 'astro.build', true), true);
			assert.equal(matchHostname(url3, '*.astro.build', true), false);
// ... (105 more lines)

Dependencies

  • node:test
  • remote
  • strict

Frequently Asked Questions

What does remote-pattern.test.js do?
remote-pattern.test.js is a source file in the astro codebase, written in javascript.
What does remote-pattern.test.js depend on?
remote-pattern.test.js imports 3 module(s): node:test, remote, strict.
Where is remote-pattern.test.js in the architecture?
remote-pattern.test.js is located at packages/astro/test/units/remote-pattern.test.js (directory: packages/astro/test/units).

Analyze Your Own Codebase

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

Try Supermodel Free