origin-pathname.test.js — astro Source File
Architecture documentation for origin-pathname.test.js, a javascript file in the astro codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c5868181_6019_6d0e_652e_1514ea8c1051["origin-pathname.test.js"] 5382515b_ef52_27a1_46c2_98231b476225["../../../dist/core/constants.js"] c5868181_6019_6d0e_652e_1514ea8c1051 --> 5382515b_ef52_27a1_46c2_98231b476225 5d6c41c7_def8_83c2_a6b3_7dc670f9e378["../../../dist/core/routing/rewrite.js"] c5868181_6019_6d0e_652e_1514ea8c1051 --> 5d6c41c7_def8_83c2_a6b3_7dc670f9e378 0e588d0c_5409_f008_bf3b_3762dd6c1c5a["strict"] c5868181_6019_6d0e_652e_1514ea8c1051 --> 0e588d0c_5409_f008_bf3b_3762dd6c1c5a fa887d9d_247c_d770_d661_490745669024["node:test"] c5868181_6019_6d0e_652e_1514ea8c1051 --> fa887d9d_247c_d770_d661_490745669024 style c5868181_6019_6d0e_652e_1514ea8c1051 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { originPathnameSymbol } from '../../../dist/core/constants.js';
import { getOriginPathname, setOriginPathname } from '../../../dist/core/routing/rewrite.js';
describe('setOriginPathname', () => {
describe('with trailingSlash = "always"', () => {
it('should append slash to pathname without extension', () => {
const request = new Request('https://example.com/about');
setOriginPathname(request, '/about', 'always', 'directory');
const stored = Reflect.get(request, originPathnameSymbol);
assert.equal(decodeURIComponent(stored), '/about/');
});
it('should append slash to pathname with extension when format is directory', () => {
const request = new Request('https://example.com/file.json');
setOriginPathname(request, '/file.json', 'always', 'directory');
const stored = Reflect.get(request, originPathnameSymbol);
assert.equal(decodeURIComponent(stored), '/file.json/');
});
it('should append slash when format is file (always means always)', () => {
const request = new Request('https://example.com/about');
setOriginPathname(request, '/about', 'always', 'file');
const stored = Reflect.get(request, originPathnameSymbol);
assert.equal(decodeURIComponent(stored), '/about/');
});
it('should keep existing trailing slash', () => {
const request = new Request('https://example.com/about/');
setOriginPathname(request, '/about/', 'always', 'directory');
const stored = Reflect.get(request, originPathnameSymbol);
assert.equal(decodeURIComponent(stored), '/about/');
});
});
describe('with trailingSlash = "never"', () => {
it('should remove trailing slash from pathname', () => {
const request = new Request('https://example.com/about/');
setOriginPathname(request, '/about/', 'never', 'directory');
const stored = Reflect.get(request, originPathnameSymbol);
assert.equal(decodeURIComponent(stored), '/about');
});
it('should not add slash to pathname without slash', () => {
const request = new Request('https://example.com/about');
setOriginPathname(request, '/about', 'never', 'directory');
const stored = Reflect.get(request, originPathnameSymbol);
assert.equal(decodeURIComponent(stored), '/about');
});
it('should remove slash from pathname with extension', () => {
const request = new Request('https://example.com/file.json/');
setOriginPathname(request, '/file.json/', 'never', 'directory');
const stored = Reflect.get(request, originPathnameSymbol);
assert.equal(decodeURIComponent(stored), '/file.json');
});
});
describe('with trailingSlash = "ignore"', () => {
// ... (70 more lines)
Domain
Dependencies
- ../../../dist/core/constants.js
- ../../../dist/core/routing/rewrite.js
- node:test
- strict
Source
Frequently Asked Questions
What does origin-pathname.test.js do?
origin-pathname.test.js is a source file in the astro codebase, written in javascript. It belongs to the TestingInfrastructure domain.
What does origin-pathname.test.js depend on?
origin-pathname.test.js imports 4 module(s): ../../../dist/core/constants.js, ../../../dist/core/routing/rewrite.js, node:test, strict.
Where is origin-pathname.test.js in the architecture?
origin-pathname.test.js is located at packages/astro/test/units/routing/origin-pathname.test.js (domain: TestingInfrastructure, directory: packages/astro/test/units/routing).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free