0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

[ci] format

This commit is contained in:
matthewp 2023-03-31 19:29:49 +00:00 committed by fredkbot
parent d54cbe4134
commit 9846b3e935
7 changed files with 17 additions and 8 deletions

View file

@ -202,7 +202,7 @@ export class App {
});
const response = await renderPage(mod, ctx, this.#env);
Reflect.set(request, responseSentSymbol, true)
Reflect.set(request, responseSentSymbol, true);
return response;
} catch (err: any) {
error(this.#logging, 'ssr', err.stack || err.message || String(err));

View file

@ -163,7 +163,7 @@ class AstroCookies implements AstroCookiesInterface {
true,
]);
if((this.#request as any)[responseSentSymbol]) {
if ((this.#request as any)[responseSentSymbol]) {
throw new AstroError({
...AstroErrorData.ResponseSentError,
});

View file

@ -199,7 +199,7 @@ export function createResult(args: CreateResultArgs): SSRResult {
redirect: args.ssr
? (path, status) => {
// If the response is already sent, error as we cannot proceed with the redirect.
if((request as any)[responseSentSymbol]) {
if ((request as any)[responseSentSymbol]) {
throw new AstroError({
...AstroErrorData.ResponseSentError,
});

View file

@ -20,7 +20,10 @@ export const decoder = new TextDecoder();
// Rendering produces either marked strings of HTML or instructions for hydration.
// These directive instructions bubble all the way up to renderPage so that we
// can ensure they are added only once, and as soon as possible.
export function stringifyChunk(result: SSRResult, chunk: string | SlotString | RenderInstruction): string {
export function stringifyChunk(
result: SSRResult,
chunk: string | SlotString | RenderInstruction
): string {
if (typeof (chunk as any).type === 'string') {
const instruction = chunk as RenderInstruction;
switch (instruction.type) {

View file

@ -99,7 +99,11 @@ export async function writeWebResponse(res: http.ServerResponse, webResponse: Re
res.end();
}
export async function writeSSRResult(webRequest: Request, webResponse: Response, res: http.ServerResponse) {
export async function writeSSRResult(
webRequest: Request,
webResponse: Response,
res: http.ServerResponse
) {
Reflect.set(webRequest, Symbol.for('astro.responseSent'), true);
return writeWebResponse(res, webResponse);
}

View file

@ -30,8 +30,10 @@ describe('Astro.redirect', () => {
try {
const text = await response.text();
expect(false).to.equal(true);
} catch(e) {
expect(e.message).to.equal('The response has already been sent to the browser and cannot be altered.');
} catch (e) {
expect(e.message).to.equal(
'The response has already been sent to the browser and cannot be altered.'
);
}
});
});

View file

@ -13,7 +13,7 @@ describe('astro/src/core/cookies', () => {
try {
cookies.set('foo', 'bar');
expect(false).to.equal(true);
} catch(err) {
} catch (err) {
expect(err.errorCode).to.equal(3030);
}
});