Skip to content

Commit d5e801b

Browse files
committed
Add logging for hostname prefix matching
1 parent 5710fa0 commit d5e801b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/http-handler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function createHttpRequestHandler(options: {
6262
? url.hostname.slice(0, -options.rootDomain.length - 1)
6363
: undefined;
6464

65-
if (path === '/' && !hostnamePrefix) {
65+
if (path === '/' && (!hostnamePrefix || hostnamePrefix === 'www')) {
6666
res.writeHead(307, {
6767
location: 'https://github.com/httptoolkit/testserver/'
6868
});
@@ -84,7 +84,11 @@ function createHttpRequestHandler(options: {
8484
);
8585

8686
if (matchingEndpoint) {
87-
console.log(`Request to ${path} matched endpoint ${matchingEndpoint.name}`);
87+
console.log(`Request to ${path}${
88+
hostnamePrefix
89+
? ` (${hostnamePrefix} prefix)`
90+
: ` (${options.rootDomain})`
91+
} matched endpoint ${matchingEndpoint.name}`);
8892
await matchingEndpoint.handle(req, res, {
8993
path,
9094
query: url.searchParams,

0 commit comments

Comments
 (0)