-
-
Notifications
You must be signed in to change notification settings - Fork 122
/
index.test-d.ts
38 lines (36 loc) · 1.67 KB
/
index.test-d.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
import {expectType} from 'tsd';
import normalizeUrl from './index.js';
expectType<string>(normalizeUrl('sindresorhus.com'));
expectType<string>(normalizeUrl('HTTP://xn--xample-hva.com:80/?b=bar&a=foo'));
normalizeUrl('//sindresorhus.com:80/', {defaultProtocol: 'https'});
normalizeUrl('//sindresorhus.com:80/', {normalizeProtocol: false});
normalizeUrl('https://sindresorhus.com:80/', {forceHttp: true});
normalizeUrl('http://sindresorhus.com:80/', {forceHttps: true});
normalizeUrl('user:password@sindresorhus.com', {stripAuthentication: false});
normalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});
normalizeUrl('https://sindresorhus.com', {stripProtocol: true});
normalizeUrl('http://www.sindresorhus.com', {stripWWW: false}); // eslint-disable-line @typescript-eslint/naming-convention
normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
removeQueryParameters: ['ref', /test/],
});
normalizeUrl('www.sindresorhus.com?foo=bar', {
removeQueryParameters: true,
});
normalizeUrl('www.sindresorhus.com?foo=bar&utm_medium=test&ref=test_ref', {
removeQueryParameters: false,
});
normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
keepQueryParameters: ['ref', /test/],
});
normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false});
normalizeUrl('http://sindresorhus.com/', {removeSingleSlash: false});
normalizeUrl('www.sindresorhus.com/foo/default.php', {
removeDirectoryIndex: [/^default\.[a-z]+$/, 'foo'],
});
normalizeUrl('www.sindresorhus.com/', {removeExplicitPort: false});
normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
sortQueryParameters: false,
});
normalizeUrl('www.sindresorhus.com/about#:~:text=hello', {
stripTextFragment: false,
});