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