Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

share.test.ts 1.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  1. import { stripAuthFromUrl } from '../src/share';
  2. jest.mock('../src/logger');
  3. describe('stripAuthFromUrl', () => {
  4. it('removes username and password from URL', () => {
  5. const input = 'https://user:pass@example.com/path?query=value#hash';
  6. const expected = 'https://example.com/path?query=value#hash';
  7. expect(stripAuthFromUrl(input)).toBe(expected);
  8. });
  9. it('handles URLs without auth info', () => {
  10. const input = 'https://example.com/path?query=value#hash';
  11. expect(stripAuthFromUrl(input)).toBe(input);
  12. });
  13. it('handles URLs with only username', () => {
  14. const input = 'https://user@example.com/path';
  15. const expected = 'https://example.com/path';
  16. expect(stripAuthFromUrl(input)).toBe(expected);
  17. });
  18. it('handles URLs with special characters in auth', () => {
  19. const input = 'https://user%40:p@ss@example.com/path';
  20. const expected = 'https://example.com/path';
  21. expect(stripAuthFromUrl(input)).toBe(expected);
  22. });
  23. it('returns original string for invalid URLs', () => {
  24. const input = 'not a valid url';
  25. expect(stripAuthFromUrl(input)).toBe(input);
  26. });
  27. it('handles URLs with IP addresses', () => {
  28. const input = 'http://user:pass@192.168.1.1:8080/path';
  29. const expected = 'http://192.168.1.1:8080/path';
  30. expect(stripAuthFromUrl(input)).toBe(expected);
  31. });
  32. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...