get.test.js — astro Source File
Architecture documentation for get.test.js, a javascript file in the astro codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 4b762a5e_c8b3_c1d4_af98_191e99d2441a["get.test.js"] d27b776e_9007_01ab_576b_331e951728d4["../../../dist/core/cookies/index.js"] 4b762a5e_c8b3_c1d4_af98_191e99d2441a --> d27b776e_9007_01ab_576b_331e951728d4 e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] 4b762a5e_c8b3_c1d4_af98_191e99d2441a --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 4b762a5e_c8b3_c1d4_af98_191e99d2441a --> 6b0635f9_51ea_77aa_767b_7857878e98a6 style 4b762a5e_c8b3_c1d4_af98_191e99d2441a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { AstroCookies } from '../../../dist/core/cookies/index.js';
const encode = (data) => {
const dataSerialized = typeof data === 'string' ? data : JSON.stringify(data);
return Buffer.from(dataSerialized).toString('base64');
};
const decode = (str) => {
return Buffer.from(str, 'base64').toString();
};
describe('astro/src/core/cookies', () => {
describe('Astro.cookies.get', () => {
it('gets the cookie value', () => {
const req = new Request('http://example.com/', {
headers: {
cookie: 'foo=bar',
},
});
const cookies = new AstroCookies(req);
assert.equal(cookies.get('foo').value, 'bar');
});
it('gets the cookie value with default decode', () => {
const url = 'http://localhost/?hello=world&foo=bar#hash';
const req = new Request('http://example.com/', {
headers: {
cookie: `url=${encodeURIComponent(url)}`,
},
});
const cookies = new AstroCookies(req);
// by default decodeURIComponent is used on the value
assert.equal(cookies.get('url').value, url);
});
it('gets the cookie value with custom decode', () => {
const url = 'http://localhost/?hello=world&foo=bar#hash';
const req = new Request('http://example.com/', {
headers: {
cookie: `url=${encode(url)}`,
},
});
const cookies = new AstroCookies(req);
assert.ok(cookies.has('url'));
assert.equal(cookies.get('url', { decode }).value, url);
assert.equal(cookies.get('url').value, encode(url));
});
it("Returns undefined is the value doesn't exist", () => {
const req = new Request('http://example.com/');
let cookies = new AstroCookies(req);
let cookie = cookies.get('foo');
assert.equal(cookie, undefined);
});
it('handles malformed cookie values gracefully', () => {
// Test with invalid URI sequence (e.g., incomplete percent encoding)
// ... (122 more lines)
Domain
Subdomains
Dependencies
- ../../../dist/core/cookies/index.js
- node:test
- strict
Source
Frequently Asked Questions
What does get.test.js do?
get.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain, SsrAdapters subdomain.
What functions are defined in get.test.js?
get.test.js defines 2 function(s): decode, encode.
What does get.test.js depend on?
get.test.js imports 3 module(s): ../../../dist/core/cookies/index.js, node:test, strict.
Where is get.test.js in the architecture?
get.test.js is located at packages/astro/test/units/cookies/get.test.js (domain: IntegrationAdapters, subdomain: SsrAdapters, directory: packages/astro/test/units/cookies).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free