renovate/lib/util/url.spec.ts
2020-12-09 13:05:31 +01:00

48 lines
2.1 KiB
TypeScript

import { resolveBaseUrl } from './url';
describe('util/url', () => {
test.each([
['http://foo.io', '', 'http://foo.io'],
['http://foo.io/', '', 'http://foo.io'],
['http://foo.io', '/', 'http://foo.io/'],
['http://foo.io/', '/', 'http://foo.io/'],
['http://foo.io', '/aaa', 'http://foo.io/aaa'],
['http://foo.io', 'aaa', 'http://foo.io/aaa'],
['http://foo.io/', '/aaa', 'http://foo.io/aaa'],
['http://foo.io/', 'aaa', 'http://foo.io/aaa'],
['http://foo.io', '/aaa/', 'http://foo.io/aaa/'],
['http://foo.io', 'aaa/', 'http://foo.io/aaa/'],
['http://foo.io/', '/aaa/', 'http://foo.io/aaa/'],
['http://foo.io/', 'aaa/', 'http://foo.io/aaa/'],
['http://foo.io/aaa', '/bbb', 'http://foo.io/aaa/bbb'],
['http://foo.io/aaa', 'bbb', 'http://foo.io/aaa/bbb'],
['http://foo.io/aaa/', '/bbb', 'http://foo.io/aaa/bbb'],
['http://foo.io/aaa/', 'bbb', 'http://foo.io/aaa/bbb'],
['http://foo.io/aaa', '/bbb/', 'http://foo.io/aaa/bbb/'],
['http://foo.io/aaa', 'bbb/', 'http://foo.io/aaa/bbb/'],
['http://foo.io/aaa/', '/bbb/', 'http://foo.io/aaa/bbb/'],
['http://foo.io/aaa/', 'bbb/', 'http://foo.io/aaa/bbb/'],
['http://foo.io', 'http://bar.io/bbb', 'http://bar.io/bbb'],
['http://foo.io/', 'http://bar.io/bbb', 'http://bar.io/bbb'],
['http://foo.io/aaa', 'http://bar.io/bbb', 'http://bar.io/bbb'],
['http://foo.io/aaa/', 'http://bar.io/bbb', 'http://bar.io/bbb'],
['http://foo.io', 'http://bar.io/bbb/', 'http://bar.io/bbb/'],
['http://foo.io/', 'http://bar.io/bbb/', 'http://bar.io/bbb/'],
['http://foo.io/aaa', 'http://bar.io/bbb/', 'http://bar.io/bbb/'],
['http://foo.io/aaa/', 'http://bar.io/bbb/', 'http://bar.io/bbb/'],
['http://foo.io', 'aaa?bbb=z', 'http://foo.io/aaa?bbb=z'],
['http://foo.io', '/aaa?bbb=z', 'http://foo.io/aaa?bbb=z'],
['http://foo.io/', 'aaa?bbb=z', 'http://foo.io/aaa?bbb=z'],
['http://foo.io/', '/aaa?bbb=z', 'http://foo.io/aaa?bbb=z'],
['http://foo.io', 'aaa/?bbb=z', 'http://foo.io/aaa?bbb=z'],
])('%s + %s => %s', (baseUrl, x, result) => {
expect(resolveBaseUrl(baseUrl, x)).toBe(result);
});
});