@@ -217,6 +217,33 @@ Deno.test("App - wrong method match", async () => {
217217 expect ( await res . text ( ) ) . toEqual ( "ok" ) ;
218218} ) ;
219219
220+ Deno . test ( "App - non-standard method does not crash handler" , async ( ) => {
221+ // Regression test for https://github.com/denoland/fresh/issues/3804
222+ // WebDAV scanners (and other clients) routinely send verbs outside the
223+ // seven methods Fresh's router declares (GET/POST/PATCH/PUT/DELETE/HEAD/
224+ // OPTIONS). Those used to surface as `methodMatch: true` with an
225+ // `undefined` item, throwing "handler2 is not a function" in production.
226+ const app = new App ( )
227+ . get ( "/" , ( ) => new Response ( "ok" ) )
228+ . get ( "/books/:id" , ( ctx ) => new Response ( ctx . params . id ) ) ;
229+
230+ const server = new FakeServer ( app . handler ( ) ) ;
231+
232+ // Static route
233+ let res = await server . request (
234+ new Request ( "http://localhost/" , { method : "PROPFIND" } ) ,
235+ ) ;
236+ expect ( res . status ) . toEqual ( 405 ) ;
237+ expect ( await res . text ( ) ) . toEqual ( "Method Not Allowed" ) ;
238+
239+ // Dynamic route
240+ res = await server . request (
241+ new Request ( "http://localhost/books/123" , { method : "PROPFIND" } ) ,
242+ ) ;
243+ expect ( res . status ) . toEqual ( 405 ) ;
244+ expect ( await res . text ( ) ) . toEqual ( "Method Not Allowed" ) ;
245+ } ) ;
246+
220247Deno . test ( "App - methods with middleware" , async ( ) => {
221248 const app = new App < { text : string } > ( )
222249 . use ( ( ctx ) => {
0 commit comments