Home / File/ bad-urls.test.js — astro Source File

bad-urls.test.js — astro Source File

Architecture documentation for bad-urls.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  2bd4703a_4d86_3170_5b40_e4140dfb504d["bad-urls.test.js"]
  760b1776_8858_e3bd_06b8_5cc4c1a9cbdc["../dist/index.js"]
  2bd4703a_4d86_3170_5b40_e4140dfb504d --> 760b1776_8858_e3bd_06b8_5cc4c1a9cbdc
  ff334e41_2760_839e_fc38_ab9318c18dfc["test-utils.js"]
  2bd4703a_4d86_3170_5b40_e4140dfb504d --> ff334e41_2760_839e_fc38_ab9318c18dfc
  0b7a6b11_e910_da4b_c617_1880167f44ef["loadFixture"]
  2bd4703a_4d86_3170_5b40_e4140dfb504d --> 0b7a6b11_e910_da4b_c617_1880167f44ef
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  2bd4703a_4d86_3170_5b40_e4140dfb504d --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  2bd4703a_4d86_3170_5b40_e4140dfb504d --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style 2bd4703a_4d86_3170_5b40_e4140dfb504d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import nodejs from '../dist/index.js';
import { loadFixture } from './test-utils.js';

describe('Bad URLs', () => {
	/** @type {import('./test-utils').Fixture} */
	let fixture;
	let devPreview;

	before(async () => {
		fixture = await loadFixture({
			root: './fixtures/bad-urls/',
			output: 'server',
			adapter: nodejs({ mode: 'standalone' }),
		});
		await fixture.build();
		devPreview = await fixture.preview();
	});

	after(async () => {
		await devPreview.stop();
	});

	it('Does not crash on bad urls', async () => {
		const weirdURLs = [
			'/\\xfs.bxss.me%3Fastrojs.com/hello-world',
			'/asdasdasd@ax_zX=.zxczas🐥%/úadasd000%/',
			'%',
			'%80',
			'%c',
			'%c0%80',
			'%20foobar%',
		];

		const statusCodes = [400, 404, 500];
		for (const weirdUrl of weirdURLs) {
			const fetchResult = await fixture.fetch(weirdUrl);
			assert.equal(
				statusCodes.includes(fetchResult.status),
				true,
				`${weirdUrl} returned something else than 400, 404, or 500`,
			);
		}
		const stillWork = await fixture.fetch('/');
		const text = await stillWork.text();
		assert.equal(text, '<!DOCTYPE html>Hello!');
	});

	it('Does not crash on URLs with hash fragments', async () => {
		// Hash fragments are client-side only and stripped before reaching the server
		// so /#foo should resolve to / and return 200 - see issue #14625
		const hashURLs = ['/#', '/#foo', '/#/path'];
		for (const hashUrl of hashURLs) {
			const fetchResult = await fixture.fetch(hashUrl);
			assert.equal(
				fetchResult.status,
				200,
				`${hashUrl} should return 200 as hash fragments are stripped`,
			);
		}
	});
});

Domain

Dependencies

Frequently Asked Questions

What does bad-urls.test.js do?
bad-urls.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does bad-urls.test.js depend on?
bad-urls.test.js imports 5 module(s): ../dist/index.js, loadFixture, node:test, strict, test-utils.js.
Where is bad-urls.test.js in the architecture?
bad-urls.test.js is located at packages/integrations/node/test/bad-urls.test.js (domain: CoreAstro, directory: packages/integrations/node/test).

Analyze Your Own Codebase

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

Try Supermodel Free