Skip to content

Commit c0383ea

Browse files
alexanderniebuhrmatthewp
andauthoredNov 29, 2023
chore: remove deprecated matchNotFound options (#9212)
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
1 parent 4ded9cd commit c0383ea

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed
 

‎.changeset/weak-wolves-bow.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': major
3+
---
4+
5+
Removes deprecated `app.match()` option, `matchNotFound`

‎packages/astro/src/core/app/index.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ const responseSentSymbol = Symbol.for('astro.responseSent');
3535

3636
const STATUS_CODES = new Set([404, 500]);
3737

38-
export interface MatchOptions {
39-
matchNotFound?: boolean | undefined;
40-
}
4138
export interface RenderErrorOptions {
4239
routeData?: RouteData;
4340
response?: Response;
@@ -133,7 +130,7 @@ export class App {
133130
return pathname;
134131
}
135132

136-
match(request: Request, _opts: MatchOptions = {}): RouteData | undefined {
133+
match(request: Request): RouteData | undefined {
137134
const url = new URL(request.url);
138135
// ignore requests matching public assets
139136
if (this.#manifest.assets.has(url.pathname)) return undefined;

‎packages/astro/src/core/app/node.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as fs from 'node:fs';
55
import { IncomingMessage } from 'node:http';
66
import { TLSSocket } from 'node:tls';
77
import { deserializeManifest } from './common.js';
8-
import { App, type MatchOptions } from './index.js';
8+
import { App } from './index.js';
99
export { apply as applyPolyfills } from '../polyfill.js';
1010

1111
const clientAddressSymbol = Symbol.for('astro.clientAddress');
@@ -108,13 +108,13 @@ class NodeIncomingMessage extends IncomingMessage {
108108
}
109109

110110
export class NodeApp extends App {
111-
match(req: NodeIncomingMessage | Request, opts: MatchOptions = {}) {
111+
match(req: NodeIncomingMessage | Request) {
112112
if (!(req instanceof Request)) {
113113
req = createRequestFromNodeRequest(req, {
114114
emptyBody: true,
115115
});
116116
}
117-
return super.match(req, opts);
117+
return super.match(req);
118118
}
119119
render(req: NodeIncomingMessage | Request, routeData?: RouteData, locals?: object) {
120120
if (!(req instanceof Request)) {

‎packages/astro/test/middleware.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe('Middleware API in PROD mode, SSR', () => {
251251

252252
it('should correctly call the middleware function for 404', async () => {
253253
const request = new Request('http://example.com/funky-url');
254-
const routeData = app.match(request, { matchNotFound: true });
254+
const routeData = app.match(request);
255255
const response = await app.render(request, routeData);
256256
const text = await response.text();
257257
expect(text.includes('Error')).to.be.true;
@@ -260,7 +260,7 @@ describe('Middleware API in PROD mode, SSR', () => {
260260

261261
it('should render 500.astro when the middleware throws an error', async () => {
262262
const request = new Request('http://example.com/throw');
263-
const routeData = app.match(request, { matchNotFound: true });
263+
const routeData = app.match(request);
264264

265265
const response = await app.render(request, routeData);
266266
expect(response).to.deep.include({ status: 500 });

‎packages/astro/test/ssr-404-500-pages.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('404 and 500 pages', () => {
5656
it('404 page returned when a route does not match and passing routeData', async () => {
5757
const app = await fixture.loadTestAdapterApp();
5858
const request = new Request('http://example.com/some/fake/route');
59-
const routeData = app.match(request, { matchNotFound: true });
59+
const routeData = app.match(request);
6060
const response = await app.render(request, routeData);
6161
expect(response.status).to.equal(404);
6262
const html = await response.text();

0 commit comments

Comments
 (0)
Please sign in to comment.