UNPKG

4.07 kBTypeScriptView Raw
1declare namespace RelateUrl {
2 interface Options {
3 /**
4 * Type: Object
5 * Default value: {ftp:21, http:80, https:443}
6 *
7 * 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/.
8 */
9 defaultPorts?: Object | undefined;
10
11 /**
12 * Type: Array
13 * Default value: ["index.html"]
14 *
15 * Extend the list with any resources you need. Works with options.removeDirectoryIndexes.
16 */
17 directoryIndexes?: string[] | undefined;
18
19 /**
20 * Type: Boolean
21 * Default value: false
22 *
23 * This will, for example, consider any domains containing http://www.example.com/ to be related to any that contain http://example.com/.
24 */
25 ignore_www?: boolean | undefined;
26
27 /**
28 * Type: constant or String
29 * Choices: RelateUrl.ABSOLUTE,RelateUrl.PATH_RELATIVE,RelateUrl.ROOT_RELATIVE,RelateUrl.SHORTEST
30 * Choices: "absolute","pathRelative","rootRelative","shortest"
31 * Default value: RelateUrl.SHORTEST
32 *
33 * RelateUrl.ABSOLUTE will produce an absolute URL. Overrides options.schemeRelative with a value of false.
34 * RelateUrl.PATH_RELATIVE will produce something like ../child-of-parent/etc/.
35 * RelateUrl.ROOT_RELATIVE will produce something like /child-of-root/etc/.
36 * RelateUrl.SHORTEST will choose whichever is shortest between root- and path-relative.
37 */
38 output?: string | undefined;
39
40 /**
41 * Type: Array
42 * Default value: ["data","javascript","mailto"]
43 *
44 * Extend the list with any additional schemes. Example: javascript:something will not be modified.
45 */
46 rejectedSchemes?: string[] | undefined;
47
48 /**
49 * Type: Boolean
50 * Default value: false
51 *
52 * Remove user authentication information from the output URL.
53 */
54 removeAuth?: boolean | undefined;
55
56 /**
57 * Type: Boolean
58 * Default value: true
59 *
60 * Remove any resources that match any found in options.directoryIndexes.
61 */
62 removeDirectoryIndexes?: boolean | undefined;
63
64 /**
65 * Type: Boolean
66 * Default value: false
67 *
68 * 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).
69 */
70 removeEmptyQueries?: boolean | undefined;
71
72 /**
73 * Type: Boolean
74 * Default value: true
75 *
76 * 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.
77 */
78 removeRootTrailingSlash?: boolean | undefined;
79
80 /**
81 * Type: Boolean
82 * Default value: true
83 *
84 * Output URLs relative to the scheme. Example: http://example.com/ will become //example.com/.
85 */
86 schemeRelative?: boolean | undefined;
87
88 /**
89 * Type: String
90 * Default value: undefined
91 *
92 * An options-based version of the from argument. If both are specified, from takes priority.
93 */
94 site?: string | undefined;
95
96 /**
97 * Type: Boolean
98 * Default value: true
99 *
100 * Passed to Node's url.parse.
101 */
102 slashesDenoteHost?: boolean | undefined;
103 }
104}
105
106declare class RelateUrl {
107 static ABSOLUTE: string;
108 static PATH_RELATIVE: string;
109 static ROOT_RELATIVE: string;
110 static SHORTEST: string;
111
112 static relate(from: string, to: string, options?: RelateUrl.Options): string;
113
114 constructor(from: string, options?: RelateUrl.Options);
115 relate(to: string, options?: RelateUrl.Options): string;
116}
117
118export = RelateUrl;