[ci] format
This commit is contained in:
parent
cfd895d877
commit
c4c616c0a5
2 changed files with 26 additions and 27 deletions
|
@ -221,19 +221,19 @@ export async function handleRoute({
|
|||
if (response.status === 404 && has404Route(manifestData)) {
|
||||
const fourOhFourRoute = await matchRoute('/404', manifestData, pipeline);
|
||||
if (fourOhFourRoute?.route !== options.route)
|
||||
return handleRoute({
|
||||
...options,
|
||||
matchedRoute: fourOhFourRoute,
|
||||
url: new URL(pathname, url),
|
||||
status: 404,
|
||||
body,
|
||||
origin,
|
||||
pipeline,
|
||||
manifestData,
|
||||
incomingRequest,
|
||||
incomingResponse,
|
||||
manifest,
|
||||
});
|
||||
return handleRoute({
|
||||
...options,
|
||||
matchedRoute: fourOhFourRoute,
|
||||
url: new URL(pathname, url),
|
||||
status: 404,
|
||||
body,
|
||||
origin,
|
||||
pipeline,
|
||||
manifestData,
|
||||
incomingRequest,
|
||||
incomingResponse,
|
||||
manifest,
|
||||
});
|
||||
}
|
||||
if (route.type === 'endpoint') {
|
||||
await writeWebResponse(incomingResponse, response);
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
import { expect } from 'chai';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
for (const caseNumber of [ 1, 2, 3, 4 ]) {
|
||||
for (const caseNumber of [1, 2, 3, 4]) {
|
||||
describe(`Custom 404 with implicit rerouting - Case #${caseNumber}`, () => {
|
||||
/** @type Awaited<ReturnType<typeof loadFixture>> */
|
||||
/** @type Awaited<ReturnType<typeof loadFixture>> */
|
||||
let fixture;
|
||||
/** @type Awaited<ReturnType<typeof fixture['startDevServer']>> */
|
||||
let devServer
|
||||
|
||||
/** @type Awaited<ReturnType<typeof fixture['startDevServer']>> */
|
||||
let devServer;
|
||||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: `./fixtures/custom-404-loop-case-${caseNumber}/`,
|
||||
site: 'http://example.com'
|
||||
site: 'http://example.com',
|
||||
});
|
||||
|
||||
|
||||
devServer = await fixture.startDevServer();
|
||||
});
|
||||
|
||||
|
@ -31,17 +31,16 @@ for (const caseNumber of [ 1, 2, 3, 4 ]) {
|
|||
expect(result).to.not.equal(timeout);
|
||||
expect(result.status).to.equal(404);
|
||||
});
|
||||
|
||||
|
||||
after(async () => {
|
||||
await devServer.stop();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/***** UTILITY FUNCTIONS *****/
|
||||
|
||||
const timeout = Symbol("timeout")
|
||||
const timeout = Symbol('timeout');
|
||||
|
||||
/** @template Res */
|
||||
function withTimeout(
|
||||
|
@ -51,7 +50,7 @@ function withTimeout(
|
|||
timeLimit
|
||||
) {
|
||||
/** @type Promise<typeof timeout> */
|
||||
const timeoutPromise = new Promise(resolve => setTimeout(() => resolve(timeout), timeLimit))
|
||||
|
||||
return Promise.race([ responsePromise, timeoutPromise ]);
|
||||
}
|
||||
const timeoutPromise = new Promise((resolve) => setTimeout(() => resolve(timeout), timeLimit));
|
||||
|
||||
return Promise.race([responsePromise, timeoutPromise]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue