forked from ProtonMail/tidy-url
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
34 lines (27 loc) · 905 Bytes
/
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
import { TidyURL } from './src';
TidyURL.silent = false;
const tests = [
// Delete test URLs before commit
''
];
for (const test of tests) {
if (test.length === 0) continue;
const link = TidyURL.clean(test);
// New options added in 1.2.8
TidyURL.allow_amp = false;
TidyURL.allow_redirects = true;
// All tests should pass before publishing
if (link.info.reduction < 0) {
console.log(link.url);
throw Error('Reduction less than 0');
}
// If last, log params
if (test === tests[tests.length - 1]) {
console.log(link.info.removed);
console.log(new URL(link.url).searchParams);
}
console.log('Input: ' + link.info.original);
console.log('Clean: ' + link.url);
console.log('New Host: ' + link.info.is_new_host);
console.log(`${link.info.reduction}% smaller (${link.info.difference} characters)\n\n`);
}