You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

origin-url.test.js 892B

1234567891011121314151617
  1. import {toOriginUrl} from './origin-url.js';
  2. test('toOriginUrl', () => {
  3. const oldLocation = window.location;
  4. for (const origin of ['https://example.com', 'https://example.com:3000']) {
  5. window.location = new URL(`${origin}/`);
  6. expect(toOriginUrl('/')).toEqual(`${origin}/`);
  7. expect(toOriginUrl('/org/repo.git')).toEqual(`${origin}/org/repo.git`);
  8. expect(toOriginUrl('https://another.com')).toEqual(`${origin}/`);
  9. expect(toOriginUrl('https://another.com/')).toEqual(`${origin}/`);
  10. expect(toOriginUrl('https://another.com/org/repo.git')).toEqual(`${origin}/org/repo.git`);
  11. expect(toOriginUrl('https://another.com:4000')).toEqual(`${origin}/`);
  12. expect(toOriginUrl('https://another.com:4000/')).toEqual(`${origin}/`);
  13. expect(toOriginUrl('https://another.com:4000/org/repo.git')).toEqual(`${origin}/org/repo.git`);
  14. }
  15. window.location = oldLocation;
  16. });