fix: Allow URLs with multiple leading slashes.

Fixes https://github.com/solid/community-server/issues/1025
This commit is contained in:
Ruben Verborgh
2021-10-25 23:38:39 +02:00
parent 2e4589938f
commit b42150cf52
2 changed files with 11 additions and 6 deletions

View File

@@ -32,6 +32,12 @@ describe('A OriginalUrlExtractor', (): void => {
.resolves.toEqual({ path: 'http://test.com/url' });
});
it('returns an input URL with multiple leading slashes.', async(): Promise<void> => {
const noQuery = new OriginalUrlExtractor({ includeQueryString: true });
await expect(noQuery.handle({ request: { url: '///url?abc=def&xyz', headers: { host: 'test.com' }} as any }))
.resolves.toEqual({ path: 'http://test.com///url?abc=def&xyz' });
});
it('drops the query string when includeQueryString is set to false.', async(): Promise<void> => {
await expect(extractor.handle({ request: { url: '/url?abc=def&xyz', headers: { host: 'test.com' }} as any }))
.resolves.toEqual({ path: 'http://test.com/url?abc=def&xyz' });