fix: Make sure all URI characters are correctly encoded

This commit is contained in:
Joachim Van Herwegen
2020-10-13 17:07:35 +02:00
parent e8e96b903d
commit e85ca622da
5 changed files with 49 additions and 29 deletions

View File

@@ -26,8 +26,14 @@ describe('A BasicTargetExtractor', (): void => {
)).resolves.toEqual({ path: 'https://test.com/url' });
});
it('decodes relevant percent encodings.', async(): Promise<void> => {
it('encodes relevant characters.', async(): Promise<void> => {
await expect(extractor.handle({ url: '/a%20path%26/name', headers: { host: 'test.com' }} as any))
.resolves.toEqual({ path: 'http://test.com/a%20path&/name' });
.resolves.toEqual({ path: 'http://test.com/a%20path%26/name' });
await expect(extractor.handle({ url: '/a path%26/name', headers: { host: 'test.com' }} as any))
.resolves.toEqual({ path: 'http://test.com/a%20path%26/name' });
await expect(extractor.handle({ url: '/path&%26/name', headers: { host: 'test.com' }} as any))
.resolves.toEqual({ path: 'http://test.com/path%26%26/name' });
});
});