Skip to content

Commit d9a43e1

Browse files
ematipicoastrobot-houston
authored andcommitted
[ci] format
1 parent 2cf79c2 commit d9a43e1

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

packages/astro/src/core/csp/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { CspDirective } from './config.js';
21
import type { SSRManifestCSP } from '../app/types.js';
2+
import type { CspDirective } from './config.js';
33

44
/**
55
* `existingDirective` is something like `img-src 'self'`. Same as `newDirective`.

packages/astro/src/core/render-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
} from './constants.js';
3232
import { AstroCookies, attachCookiesToResponse } from './cookies/index.js';
3333
import { getCookiesFromResponse } from './cookies/response.js';
34+
import { pushDirective } from './csp/runtime.js';
3435
import { generateCspDigest } from './encryption.js';
3536
import { CspNotEnabled, ForbiddenRewrite } from './errors/errors-data.js';
3637
import { AstroError, AstroErrorData } from './errors/index.js';
@@ -42,7 +43,6 @@ import { isRoute404or500, isRouteExternalRedirect, isRouteServerIsland } from '.
4243
import { copyRequest, getOriginPathname, setOriginPathname } from './routing/rewrite.js';
4344
import { AstroSession } from './session.js';
4445
import { validateAndDecodePathname } from './util/pathname.js';
45-
import { pushDirective } from './csp/runtime.js';
4646

4747
export const apiContextRoutesSymbol = Symbol.for('context.routes');
4848
/**

packages/astro/test/csp.test.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,17 @@ describe('CSP', () => {
197197
const meta = $('meta[http-equiv="Content-Security-Policy"]');
198198
// correctness for resources
199199
assert.ok(
200-
meta.attr('content').toString().includes('script-src https://global.cdn.example.com https://scripts.cdn.example.com'),
200+
meta
201+
.attr('content')
202+
.toString()
203+
.includes('script-src https://global.cdn.example.com https://scripts.cdn.example.com'),
201204
);
202205
assert.ok(meta.attr('content').toString().includes("style-src 'self'"));
203206
// correctness for hashes
204207
assert.ok(meta.attr('content').toString().includes("default-src 'self';"));
205-
assert.ok(meta.attr('content').toString().includes("img-src 'self' https://images.cdn.example.com;"));
208+
assert.ok(
209+
meta.attr('content').toString().includes("img-src 'self' https://images.cdn.example.com;"),
210+
);
206211
});
207212

208213
it('allows injecting custom styles resources and hashes based on pages', async () => {
@@ -223,11 +228,18 @@ describe('CSP', () => {
223228

224229
const meta = $('meta[http-equiv="Content-Security-Policy"]');
225230
// correctness for resources
226-
assert.ok(meta.attr('content').toString().includes('style-src https://global.cdn.example.com https://styles.cdn.example.com'));
231+
assert.ok(
232+
meta
233+
.attr('content')
234+
.toString()
235+
.includes('style-src https://global.cdn.example.com https://styles.cdn.example.com'),
236+
);
227237
assert.ok(meta.attr('content').toString().includes("script-src 'self'"));
228238
// correctness for hashes
229239
assert.ok(meta.attr('content').toString().includes("default-src 'self';"));
230-
assert.ok(meta.attr('content').toString().includes("img-src 'self' https://images.cdn.example.com;"));
240+
assert.ok(
241+
meta.attr('content').toString().includes("img-src 'self' https://images.cdn.example.com;"),
242+
);
231243
});
232244

233245
it('allows add `strict-dynamic` when enabled', async () => {

packages/astro/test/units/csp/common.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
3-
import { getDirectives, } from '../../../dist/core/csp/common.js';
3+
import { getDirectives } from '../../../dist/core/csp/common.js';
44

55
/**
66
*

packages/astro/test/units/csp/runtime.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// @ts-check
22
import assert from 'node:assert/strict';
33
import { describe, it } from 'node:test';
4-
import {
5-
deduplicateDirectiveValues,
6-
pushDirective,
7-
} from '../../../dist/core/csp/runtime.js';
4+
import { deduplicateDirectiveValues, pushDirective } from '../../../dist/core/csp/runtime.js';
85

96
describe('deduplicateDirectiveValues', () => {
107
it('merges directives', () => {
@@ -32,7 +29,10 @@ describe('deduplicateDirectiveValues', () => {
3229
});
3330

3431
it('handle multiple spaces', () => {
35-
let result = deduplicateDirectiveValues("img-src 'self' ", "img-src 'self' https://example.com");
32+
let result = deduplicateDirectiveValues(
33+
"img-src 'self' ",
34+
"img-src 'self' https://example.com",
35+
);
3636

3737
assert.deepStrictEqual(result, "img-src 'self' https://example.com");
3838
});

0 commit comments

Comments
 (0)