1 import { getLocalID } from './localid';
3 describe('getLocalID', () => {
4 test('extracts local ID from valid URL', () => {
5 const url = 'https://drive.proton.me/u/123/some-path';
6 expect(getLocalID(url)).toBe('123');
9 test('returns null for URL without local ID', () => {
10 const url = 'https://drive.proton.me/some-path';
11 expect(getLocalID(url)).toBeNull();
14 test('returns null for invalid URL', () => {
15 const url = 'not-a-valid-url';
16 expect(getLocalID(url)).toBeNull();
19 test('returns null when local ID is not present in correct format', () => {
20 const url = 'https://drive.proton.me/123/u/some-path';
21 expect(getLocalID(url)).toBeNull();
24 test('correctly handles multiple numbers in URL', () => {
25 const url = 'https://drive.proton.me/u/789/some/123/path';
26 expect(getLocalID(url)).toBe('789');
29 test('returns null for URL with /u/ but no number', () => {
30 const url = 'https://drive.proton.me/u//some-path';
31 expect(getLocalID(url)).toBeNull();
34 test('handles URL with query parameters', () => {
35 const url = 'https://drive.proton.me/u/101/some-path?param=value';
36 expect(getLocalID(url)).toBe('101');