stripOrigin.spec.tsx 697 B

123456789101112131415161718192021
  1. import stripOrigin from 'sentry/utils/url/stripOrigin';
  2. describe('stripOrigin', () => {
  3. it('should preserve the url path, query, and hash', () => {
  4. expect(stripOrigin('https://example.com/path/name?query=params#hash')).toEqual(
  5. '/path/name?query=params#hash'
  6. );
  7. });
  8. it.each([
  9. 'foo bar baz',
  10. '/path/name?query=params#hash',
  11. '/[a-z]@[a-z].com/',
  12. 'nulltext/html;base64,PHNjcmlwdD4KICAgICAgb25tZXNzYWdlID0gKGV2ZW50KSA9PiB7CiAgICAgICAgY29uc29sZS5sb2coJ2hlbGxvIHdvcmxkJyk7CiAgICAgIH0KICA8L3NjcmlwdD4=',
  13. ])(
  14. 'should return the the same string, when something is not parseable as a url',
  15. str => {
  16. expect(stripOrigin(str)).toEqual(str);
  17. }
  18. );
  19. });