fix: Add trailing slashes to advertised WebSocket URL.

This commit is contained in:
Ruben Verborgh
2020-11-30 00:36:02 +01:00
parent fc3942b372
commit 6b4088723d
3 changed files with 6 additions and 6 deletions

View File

@@ -6,28 +6,28 @@ describe('A WebSocketAdvertiser', (): void => {
const writer = new WebSocketAdvertiser();
const response = createResponse();
await writer.handle({ response } as any);
expect(response.getHeaders()).toEqual({ 'updates-via': 'ws://localhost' });
expect(response.getHeaders()).toEqual({ 'updates-via': 'ws://localhost/' });
});
it('writes an HTTP WebSocket with port 80.', async(): Promise<void> => {
const writer = new WebSocketAdvertiser({ hostname: 'test.example', port: 80, protocol: 'http' });
const response = createResponse();
await writer.handle({ response } as any);
expect(response.getHeaders()).toEqual({ 'updates-via': 'ws://test.example' });
expect(response.getHeaders()).toEqual({ 'updates-via': 'ws://test.example/' });
});
it('writes an HTTP WebSocket with port 3000.', async(): Promise<void> => {
const writer = new WebSocketAdvertiser({ hostname: 'test.example', port: 3000, protocol: 'http' });
const response = createResponse();
await writer.handle({ response } as any);
expect(response.getHeaders()).toEqual({ 'updates-via': 'ws://test.example:3000' });
expect(response.getHeaders()).toEqual({ 'updates-via': 'ws://test.example:3000/' });
});
it('writes an HTTPS WebSocket with port 443.', async(): Promise<void> => {
const writer = new WebSocketAdvertiser({ hostname: 'test.example', port: 443, protocol: 'https' });
const response = createResponse();
await writer.handle({ response } as any);
expect(response.getHeaders()).toEqual({ 'updates-via': 'wss://test.example' });
expect(response.getHeaders()).toEqual({ 'updates-via': 'wss://test.example/' });
});
it('rejects an invalid hostname.', (): void => {