import { decodeUriPathComponents, encodeUriPathComponents, ensureTrailingSlash, toCanonicalUriPath, } from '../../../src/util/PathUtil'; describe('PathUtil', (): void => { describe('#ensureTrailingSlash', (): void => { it('makes sure there is always exactly 1 slash.', async(): Promise => { expect(ensureTrailingSlash('http://test.com')).toEqual('http://test.com/'); expect(ensureTrailingSlash('http://test.com/')).toEqual('http://test.com/'); expect(ensureTrailingSlash('http://test.com//')).toEqual('http://test.com/'); expect(ensureTrailingSlash('http://test.com///')).toEqual('http://test.com/'); }); }); describe('UriPath functions', (): void => { it('makes sure only the necessary parts are encoded with toCanonicalUriPath.', async(): Promise => { expect(toCanonicalUriPath('/a%20path&/name')).toEqual('/a%20path%26/name'); }); it('decodes all parts of a path with decodeUriPathComponents.', async(): Promise => { expect(decodeUriPathComponents('/a%20path&/name')).toEqual('/a path&/name'); }); it('encodes all parts of a path with encodeUriPathComponents.', async(): Promise => { expect(encodeUriPathComponents('/a%20path&/name')).toEqual('/a%2520path%26/name'); }); }); });