|
| 1 | +import {normalizePathSlashes} from '../'; |
| 2 | + |
| 3 | +describe('normalizePathSlashes', () => { |
| 4 | + test('should handle empty strings', () => { |
| 5 | + expect(normalizePathSlashes('')).toBe(''); |
| 6 | + }); |
| 7 | + test('should handle strings without slashes', () => { |
| 8 | + expect(normalizePathSlashes('path')).toBe('path'); |
| 9 | + }); |
| 10 | + test('should handle paths with single slash', () => { |
| 11 | + expect(normalizePathSlashes('/path')).toBe('/path'); |
| 12 | + }); |
| 13 | + test('should handle paths with trailing slash', () => { |
| 14 | + expect(normalizePathSlashes('path/')).toBe('path/'); |
| 15 | + }); |
| 16 | + test('should handle paths with multiple trailing slashes', () => { |
| 17 | + expect(normalizePathSlashes('path////')).toBe('path/'); |
| 18 | + }); |
| 19 | + test('should handle full paths with normal slashes', () => { |
| 20 | + expect(normalizePathSlashes('http://example.com/path/to/resource')).toBe( |
| 21 | + 'http://example.com/path/to/resource', |
| 22 | + ); |
| 23 | + }); |
| 24 | + test('should replace multiple slashes with a single slash', () => { |
| 25 | + expect(normalizePathSlashes('http://example.com//path//to////resource')).toBe( |
| 26 | + 'http://example.com/path/to/resource', |
| 27 | + ); |
| 28 | + }); |
| 29 | + test('should replace slashes more than two slashes after a colon', () => { |
| 30 | + expect(normalizePathSlashes('http://///example.com/path/to/resource')).toBe( |
| 31 | + 'http://example.com/path/to/resource', |
| 32 | + ); |
| 33 | + }); |
| 34 | +}); |
0 commit comments