-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathnormalize-url.test.ts
65 lines (51 loc) · 2.49 KB
/
normalize-url.test.ts
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { describe, expect, it } from 'vitest';
import { normalizeUrlToBase } from '../../src/utils-hoist/normalize';
describe('normalizeUrlToBase()', () => {
it('Example app on Windows', () => {
const base = 'c:/Users/Username/sentry-electron/example';
expect(normalizeUrlToBase('C:\\Users\\Username\\sentry-electron\\example\\renderer.js', base)).toEqual(
'app:///renderer.js',
);
expect(
normalizeUrlToBase('C:\\Users\\Username\\sentry-electron\\example\\sub-directory\\renderer.js', base),
).toEqual('app:///sub-directory/renderer.js');
expect(normalizeUrlToBase('file:///C:/Users/Username/sentry-electron/example/index.html', base)).toEqual(
'app:///index.html',
);
});
it('Example app with parentheses', () => {
const base = 'c:/Users/Username/sentry-electron (beta)/example';
expect(normalizeUrlToBase('C:\\Users\\Username\\sentry-electron%20(beta)\\example\\renderer.js', base)).toEqual(
'app:///renderer.js',
);
expect(
normalizeUrlToBase('C:\\Users\\Username\\sentry-electron%20(beta)\\example\\sub-directory\\renderer.js', base),
).toEqual('app:///sub-directory/renderer.js');
expect(normalizeUrlToBase('file:///C:/Users/Username/sentry-electron%20(beta)/example/index.html', base)).toEqual(
'app:///index.html',
);
});
it('Asar packaged app in Windows Program Files', () => {
const base = 'C:/Program Files/My App/resources/app.asar';
expect(normalizeUrlToBase('/C:/Program%20Files/My%20App/resources/app.asar/dist/bundle-app.js', base)).toEqual(
'app:///dist/bundle-app.js',
);
expect(normalizeUrlToBase('file:///C:/Program%20Files/My%20App/resources/app.asar/index.html', base)).toEqual(
'app:///index.html',
);
expect(normalizeUrlToBase('file:///C:/Program%20Files/My%20App/resources/app.asar/a/index.html', base)).toEqual(
'app:///a/index.html',
);
});
it('Webpack builds', () => {
const base = '/home/haza/Desktop/foo/app/';
expect(
normalizeUrlToBase('/home/haza/Desktop/foo/app/webpack:/electron/src/common/models/ipc-request.ts', base),
).toEqual('app:///electron/src/common/models/ipc-request.ts');
});
it('Only modifies file URLS', () => {
const base = 'c:/Users/Username/sentry-electron/example';
expect(normalizeUrlToBase('https://some.host/index.html', base)).toEqual('https://some.host/index.html');
expect(normalizeUrlToBase('http://localhost:43288/index.html', base)).toEqual('http://localhost:43288/index.html');
});
});