csp.ts — astro Source File
Architecture documentation for csp.ts, a typescript file in the astro codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 678da59a_6955_fac5_4ead_acfc331bfdcc["csp.ts"] baa53824_73a3_1e03_2043_4d0c058ecca5["../types/public/index.js"] 678da59a_6955_fac5_4ead_acfc331bfdcc --> baa53824_73a3_1e03_2043_4d0c058ecca5 style 678da59a_6955_fac5_4ead_acfc331bfdcc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { SSRResult } from '../../../types/public/index.js';
export function renderCspContent(result: SSRResult): string {
const finalScriptHashes = new Set();
const finalStyleHashes = new Set();
for (const scriptHash of result.scriptHashes) {
finalScriptHashes.add(`'${scriptHash}'`);
}
for (const styleHash of result.styleHashes) {
finalStyleHashes.add(`'${styleHash}'`);
}
for (const styleHash of result._metadata.extraStyleHashes) {
finalStyleHashes.add(`'${styleHash}'`);
}
for (const scriptHash of result._metadata.extraScriptHashes) {
finalScriptHashes.add(`'${scriptHash}'`);
}
let directives;
if (result.directives.length > 0) {
directives = result.directives.join(';') + ';';
}
let scriptResources = "'self'";
if (result.scriptResources.length > 0) {
scriptResources = result.scriptResources.map((r) => `${r}`).join(' ');
}
let styleResources = "'self'";
if (result.styleResources.length > 0) {
styleResources = result.styleResources.map((r) => `${r}`).join(' ');
}
const strictDynamic = result.isStrictDynamic ? ` 'strict-dynamic'` : '';
const scriptSrc = `script-src ${scriptResources} ${Array.from(finalScriptHashes).join(' ')}${strictDynamic};`;
const styleSrc = `style-src ${styleResources} ${Array.from(finalStyleHashes).join(' ')};`;
return [directives, scriptSrc, styleSrc].filter(Boolean).join(' ');
}
Domain
Subdomains
Functions
Dependencies
- ../types/public/index.js
Source
Frequently Asked Questions
What does csp.ts do?
csp.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in csp.ts?
csp.ts defines 1 function(s): renderCspContent.
What does csp.ts depend on?
csp.ts imports 1 module(s): ../types/public/index.js.
Where is csp.ts in the architecture?
csp.ts is located at packages/astro/src/runtime/server/render/csp.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/runtime/server/render).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free