-
Notifications
You must be signed in to change notification settings - Fork 65
/
index.d.ts
50 lines (37 loc) · 1.07 KB
/
index.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
39
40
41
42
43
44
45
46
47
48
49
50
declare namespace urlRegex {
interface Options {
/**
Only match an exact string. Useful with `RegExp#test` to check if a string is a URL.
@default false
*/
readonly exact?: boolean;
/**
Force URLs to start with a valid protocol or `www`. If set to `false` it'll match the TLD against a list of valid [TLDs](https://github.com/stephenmathieson/node-tlds).
@default true
*/
readonly strict?: boolean;
}
}
/**
Regular expression for matching URLs.
@example
```
import urlRegex = require('url-regex');
urlRegex().test('http://github.com foo bar');
//=> true
urlRegex().test('www.github.com foo bar');
//=> true
urlRegex({exact: true}).test('http://github.com foo bar');
//=> false
urlRegex({exact: true}).test('http://github.com');
//=> true
urlRegex({strict: false}).test('github.com foo bar');
//=> true
urlRegex({exact: true, strict: false}).test('github.com');
//=> true
'foo http://github.com bar //google.com'.match(urlRegex());
//=> ['http://github.com', '//google.com']
```
*/
declare function urlRegex(options?: urlRegex.Options): RegExp;
export = urlRegex;