Skip to content

Commit afb15c1

Browse files
committed
types: allow server.match to receive lowercased methods
1 parent 200a5af commit afb15c1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/types/server/server.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ export class Server<A = ServerApplicationState> {
475475
* @return Return value: the route information if found, otherwise null.
476476
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermatchmethod-path-host)
477477
*/
478-
match(method: HTTP_METHODS, path: string, host?: string | undefined): RequestRoute | null;
478+
match(method: HTTP_METHODS | Lowercase<HTTP_METHODS>, path: string, host?: string | undefined): RequestRoute | null;
479479

480480
/**
481481
* Registers a server method where:

test/types/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { expect } from '@hapi/code';
44
import {
55
Plugin,
66
Request,
7+
RequestRoute,
78
ResponseToolkit,
89
Server,
910
ServerRoute,
@@ -77,7 +78,7 @@ const plugin: Plugin<TestPluginOptions, TestPluginDecorations> = {
7778
register: function (srv: MyServer, options) {
7879

7980
check.type<TestPluginOptions>(options);
80-
81+
8182
srv.expose({
8283
add: function (a: number, b: number) {
8384

@@ -89,6 +90,9 @@ const plugin: Plugin<TestPluginOptions, TestPluginDecorations> = {
8990

9091
const loadedServer = await server.register({ plugin, options: { x: 10 } });
9192

93+
check.type<RequestRoute | null>(server.match('GET', '/'));
94+
check.type<RequestRoute | null>(server.match('get', '/'));
95+
9296
const sum = loadedServer.plugins.test.add(1, 2);
9397
expect(sum).to.equal(130);
9498
check.type<number>(sum);

0 commit comments

Comments
 (0)