forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
relateurl.d.ts
125 lines (109 loc) · 3.92 KB
/
relateurl.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Type definitions for relateurl v0.2.6
// Project: https://github.com/stevenvachon/relateurl
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'relateurl' {
namespace RelateUrl {
interface Options {
/**
* Type: Object
* Default value: {ftp:21, http:80, https:443}
*
* Extend the list with any ports you need. Any URLs containing these default ports will have them removed. Example: http://example.com:80/ will become http://example.com/.
*/
defaultPorts?: Object;
/**
* Type: Array
* Default value: ["index.html"]
*
* Extend the list with any resources you need. Works with options.removeDirectoryIndexes.
*/
directoryIndexes?: Array<string>;
/**
* Type: Boolean
* Default value: false
*
* This will, for example, consider any domains containing http://www.example.com/ to be related to any that contain http://example.com/.
*/
ignore_www?: boolean;
/**
* Type: constant or String
* Choices: RelateUrl.ABSOLUTE,RelateUrl.PATH_RELATIVE,RelateUrl.ROOT_RELATIVE,RelateUrl.SHORTEST
* Choices: "absolute","pathRelative","rootRelative","shortest"
* Default value: RelateUrl.SHORTEST
*
* RelateUrl.ABSOLUTE will produce an absolute URL. Overrides options.schemeRelative with a value of false.
* RelateUrl.PATH_RELATIVE will produce something like ../child-of-parent/etc/.
* RelateUrl.ROOT_RELATIVE will produce something like /child-of-root/etc/.
* RelateUrl.SHORTEST will choose whichever is shortest between root- and path-relative.
*/
output?: string;
/**
* Type: Array
* Default value: ["data","javascript","mailto"]
*
* Extend the list with any additional schemes. Example: javascript:something will not be modified.
*/
rejectedSchemes?: Array<string>;
/**
* Type: Boolean
* Default value: false
*
* Remove user authentication information from the output URL.
*/
removeAuth?: boolean;
/**
* Type: Boolean
* Default value: true
*
* Remove any resources that match any found in options.directoryIndexes.
*/
removeDirectoryIndexes?: boolean;
/**
* Type: Boolean
* Default value: false
*
* Remove empty query variables. Example: http://domain.com/?var1&var2=&var3=asdf will become http://domain.com/?var3=adsf. This does not apply to unrelated URLs (with other protocols, auths, hosts and/or ports).
*/
removeEmptyQueries?: boolean;
/**
* Type: Boolean
* Default value: true
*
* Remove trailing slashes from root paths. Example: http://domain.com/?var will become http://domain.com?var while http://domain.com/dir/?var will not be modified.
*/
removeRootTrailingSlash?: boolean;
/**
* Type: Boolean
* Default value: true
*
* Output URLs relative to the scheme. Example: http://example.com/ will become //example.com/.
*/
schemeRelative?: boolean;
/**
* Type: String
* Default value: undefined
*
* An options-based version of the from argument. If both are specified, from takes priority.
*/
site?: string;
/**
* Type: Boolean
* Default value: true
*
* Passed to Node's url.parse.
*/
slashesDenoteHost?: boolean;
}
}
class RelateUrl {
static ABSOLUTE: string;
static PATH_RELATIVE: string;
static ROOT_RELATIVE: string;
static SHORTEST: string;
static relate(from: string, to: string, options?: RelateUrl.Options): string;
constructor(from: string, options?: RelateUrl.Options);
relate(to: string, options?: RelateUrl.Options): string;
}
export = RelateUrl;
}