fix: Do not add port 80 to default base URL

This commit is contained in:
Joachim Van Herwegen 2023-02-09 16:39:46 +01:00
parent c332412074
commit bb7427842c
2 changed files with 7 additions and 1 deletions

View File

@ -22,6 +22,8 @@ export class BaseUrlExtractor extends ShorthandExtractor {
throw new Error('BaseUrl argument should be provided when using Unix Domain Sockets.');
}
const port = args.port ?? this.defaultPort;
return `http://localhost:${port}/`;
const url = new URL('http://localhost/');
url.port = `${port}`;
return url.href;
}
}

View File

@ -24,4 +24,8 @@ describe('A BaseUrlExtractor', (): void => {
it('defaults to port 3000.', async(): Promise<void> => {
await expect(computer.handle({})).resolves.toBe('http://localhost:3000/');
});
it('does not add the port if it is 80.', async(): Promise<void> => {
await expect(computer.handle({ port: 80 })).resolves.toBe('http://localhost/');
});
});