mirror of
https://github.com/withastro/astro.git
synced 2025-04-07 23:41:43 -05:00
chore: remove deprecated matchNotFound
options (#9212)
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
This commit is contained in:
parent
4ded9cd1bc
commit
c0383ea0c1
5 changed files with 12 additions and 10 deletions
5
.changeset/weak-wolves-bow.md
Normal file
5
.changeset/weak-wolves-bow.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': major
|
||||
---
|
||||
|
||||
Removes deprecated `app.match()` option, `matchNotFound`
|
|
@ -35,9 +35,6 @@ const responseSentSymbol = Symbol.for('astro.responseSent');
|
|||
|
||||
const STATUS_CODES = new Set([404, 500]);
|
||||
|
||||
export interface MatchOptions {
|
||||
matchNotFound?: boolean | undefined;
|
||||
}
|
||||
export interface RenderErrorOptions {
|
||||
routeData?: RouteData;
|
||||
response?: Response;
|
||||
|
@ -133,7 +130,7 @@ export class App {
|
|||
return pathname;
|
||||
}
|
||||
|
||||
match(request: Request, _opts: MatchOptions = {}): RouteData | undefined {
|
||||
match(request: Request): RouteData | undefined {
|
||||
const url = new URL(request.url);
|
||||
// ignore requests matching public assets
|
||||
if (this.#manifest.assets.has(url.pathname)) return undefined;
|
||||
|
|
|
@ -5,7 +5,7 @@ import * as fs from 'node:fs';
|
|||
import { IncomingMessage } from 'node:http';
|
||||
import { TLSSocket } from 'node:tls';
|
||||
import { deserializeManifest } from './common.js';
|
||||
import { App, type MatchOptions } from './index.js';
|
||||
import { App } from './index.js';
|
||||
export { apply as applyPolyfills } from '../polyfill.js';
|
||||
|
||||
const clientAddressSymbol = Symbol.for('astro.clientAddress');
|
||||
|
@ -108,13 +108,13 @@ class NodeIncomingMessage extends IncomingMessage {
|
|||
}
|
||||
|
||||
export class NodeApp extends App {
|
||||
match(req: NodeIncomingMessage | Request, opts: MatchOptions = {}) {
|
||||
match(req: NodeIncomingMessage | Request) {
|
||||
if (!(req instanceof Request)) {
|
||||
req = createRequestFromNodeRequest(req, {
|
||||
emptyBody: true,
|
||||
});
|
||||
}
|
||||
return super.match(req, opts);
|
||||
return super.match(req);
|
||||
}
|
||||
render(req: NodeIncomingMessage | Request, routeData?: RouteData, locals?: object) {
|
||||
if (!(req instanceof Request)) {
|
||||
|
|
|
@ -251,7 +251,7 @@ describe('Middleware API in PROD mode, SSR', () => {
|
|||
|
||||
it('should correctly call the middleware function for 404', async () => {
|
||||
const request = new Request('http://example.com/funky-url');
|
||||
const routeData = app.match(request, { matchNotFound: true });
|
||||
const routeData = app.match(request);
|
||||
const response = await app.render(request, routeData);
|
||||
const text = await response.text();
|
||||
expect(text.includes('Error')).to.be.true;
|
||||
|
@ -260,7 +260,7 @@ describe('Middleware API in PROD mode, SSR', () => {
|
|||
|
||||
it('should render 500.astro when the middleware throws an error', async () => {
|
||||
const request = new Request('http://example.com/throw');
|
||||
const routeData = app.match(request, { matchNotFound: true });
|
||||
const routeData = app.match(request);
|
||||
|
||||
const response = await app.render(request, routeData);
|
||||
expect(response).to.deep.include({ status: 500 });
|
||||
|
|
|
@ -56,7 +56,7 @@ describe('404 and 500 pages', () => {
|
|||
it('404 page returned when a route does not match and passing routeData', async () => {
|
||||
const app = await fixture.loadTestAdapterApp();
|
||||
const request = new Request('http://example.com/some/fake/route');
|
||||
const routeData = app.match(request, { matchNotFound: true });
|
||||
const routeData = app.match(request);
|
||||
const response = await app.render(request, routeData);
|
||||
expect(response.status).to.equal(404);
|
||||
const html = await response.text();
|
||||
|
|
Loading…
Add table
Reference in a new issue