[Options] Policy

This commit is contained in:
Patryk Rzucidlo (PTKDev)
2023-02-09 22:10:51 +01:00
parent ca90c1dcc3
commit d7a4a3789f
2 changed files with 22 additions and 6 deletions

3
index.d.ts vendored
View File

@@ -1,4 +1,4 @@
import { Adapter } from '@sveltejs/kit'; import { Adapter } from "@sveltejs/kit";
export interface AdapterOptions { export interface AdapterOptions {
pages?: string; pages?: string;
@@ -6,6 +6,7 @@ export interface AdapterOptions {
fallback?: string; fallback?: string;
precompress?: boolean; precompress?: boolean;
strict?: boolean; strict?: boolean;
policy?: string;
} }
export default function plugin(options?: AdapterOptions): Adapter; export default function plugin(options?: AdapterOptions): Adapter;

View File

@@ -114,6 +114,21 @@ See https://kit.svelte.dev/docs/page-options#prerender for more details`
}); });
}); });
let regex_input = new RegExp(
`http-equiv="content-security-policy" content=""`,
"g"
);
const policy = "";
let regex_replace = `http-equiv="content-security-policy" content="${
options?.policy ? options.policy : policy
}"`;
await replace.sync({
files: [pages + "/**/*.html"],
// @ts-ignore
processor: (input) => input.replace(regex_input, regex_replace),
});
const HTML_assets = await glob("_app/**/*", { const HTML_assets = await glob("_app/**/*", {
cwd: pages, cwd: pages,
dot: true, dot: true,