1 | /**
|
2 | * Helper functions related to path manipulation.
|
3 | *
|
4 | * @namespace PathUtils
|
5 | */
|
6 | export declare class PathUtils {
|
7 | /**
|
8 | * Returns if the code executes in the browser context or not by checking for the
|
9 | * existance of the window object
|
10 | *
|
11 | * @returns {Boolean} the result of the check of the existance of the window object
|
12 | */
|
13 | static isBrowser(): boolean;
|
14 | /**
|
15 | * Returns the context path of the given location.
|
16 | * If no location is provided, it fallbacks to the current location.
|
17 | * @param {String} [location] - Location to be used to detect the context path from.
|
18 | * @returns {String}
|
19 | */
|
20 | static getContextPath(location?: string | null): string;
|
21 | /**
|
22 | * Adapts the provided path to a valid model path.
|
23 | * Returns an empty string if the given path is equal to the root model path.
|
24 | * This function is a utility tool that converts a provided root model path into an internal specific empty path
|
25 | *
|
26 | * @param {string} [path] - raw model path
|
27 | * @return {string} the valid model path
|
28 | *
|
29 | * @private
|
30 | */
|
31 | static adaptPagePath(path: string, rootPath?: string): string;
|
32 | /**
|
33 | * Returns the given URL externalized by adding the optional context path
|
34 | *
|
35 | * @param {string} url - URL to externalize
|
36 | * @returns {string}
|
37 | */
|
38 | static externalize(url: string): string;
|
39 | /**
|
40 | * Returns the given URL internalized by removing the optional context path
|
41 | *
|
42 | * @param {string|null} url - URL to internalize
|
43 | * @returns {string}
|
44 | */
|
45 | static internalize(url: string | null): string;
|
46 | /**
|
47 | * Returns the value of the meta property with the given key
|
48 | *
|
49 | * @param {string} propertyName - name of the meta property
|
50 | * @return {string|null}
|
51 | */
|
52 | static getMetaPropertyValue(propertyName: string): string | null;
|
53 | /**
|
54 | * Returns a model path for the given URL
|
55 | *
|
56 | * @param {string} url - Raw URL for which to get a model URL
|
57 | * @return {string|undefined}
|
58 | */
|
59 | static convertToModelUrl(url: string): string | undefined;
|
60 | /**
|
61 | * Returns the model URL as contained in the current page URL
|
62 | *
|
63 | * @return {string|null}
|
64 | */
|
65 | static getCurrentPageModelUrl(): string | null;
|
66 | /**
|
67 | * Returns the URL of the page model to initialize the page model manager with.
|
68 | * It is either derived from a meta tag property called 'cq:pagemodel_root_url' or from the given location.
|
69 | * If no location is provided, it derives it from the current location.
|
70 | *
|
71 | * @param {String} [url] - path or URL to be used to derive the page model URL from
|
72 | * @returns {String}
|
73 | */
|
74 | static getModelUrl(url?: string): string | null | undefined;
|
75 | /**
|
76 | * Returns the given path after sanitizing it.
|
77 | * This function should be called on page paths before storing them in the page model,
|
78 | * to make sure only properly formatted paths (e.g., "/content/mypage") are stored.
|
79 | * @param {string} path - Path of the page to be sanitized.
|
80 | * @return {string}
|
81 | */
|
82 | static sanitize(path: string | null): string | null | undefined;
|
83 | /**
|
84 | * Returns the given path extended with the given extension.
|
85 | * @param {String} path - Path to be extended.
|
86 | * @param {String} extension - Extension to be added.
|
87 | * @returns {String}
|
88 | */
|
89 | static addExtension(path: string, extension: string): string;
|
90 | /**
|
91 | * Returns the given path extended with the given selector.
|
92 | * @param {String} path - Path to be extended.
|
93 | * @param {String} selector - Selector to be added.
|
94 | * @returns {String}
|
95 | */
|
96 | static addSelector(path: string, selector: string): string;
|
97 | /**
|
98 | * Returns the current location as a string.
|
99 | * @returns {String}
|
100 | */
|
101 | static getCurrentPathname(): string | null;
|
102 | /**
|
103 | * Dispatches a custom event on the window object, when in the browser context.
|
104 | *
|
105 | * @param {String} eventName - the name of the custom event
|
106 | * @param {Object} options - the custom event options
|
107 | */
|
108 | static dispatchGlobalCustomEvent(eventName: string, options: any): void;
|
109 | /**
|
110 | * Joins given path segments into a string using slash.
|
111 | *
|
112 | * @param paths
|
113 | * @returns {string}
|
114 | */
|
115 | static join(paths?: string[]): string;
|
116 | /**
|
117 | * Normalizes given path by replacing repeated slash with a single one.
|
118 | *
|
119 | * @param {string} path
|
120 | * @returns {string}
|
121 | */
|
122 | static normalize(path?: string): string;
|
123 | /**
|
124 | * Returns path that starts with slash.
|
125 | *
|
126 | * @param {string} path
|
127 | * @returns {string}
|
128 | */
|
129 | static makeAbsolute(path?: string): string;
|
130 | /**
|
131 | * Returns path without the leading slash.
|
132 | *
|
133 | * @param path
|
134 | * @returns {string}
|
135 | */
|
136 | static makeRelative(path?: string): string;
|
137 | /**
|
138 | * Returns path to the direct parent
|
139 | *
|
140 | * @param path
|
141 | * @returns {string|null}
|
142 | */
|
143 | static getParentNodePath(path: string | null): string | null;
|
144 | /**
|
145 | * Checks if given path is an JCR path
|
146 | *
|
147 | * @param path
|
148 | * @returns {boolean}
|
149 | */
|
150 | static isItem(path: string): boolean;
|
151 | /**
|
152 | * Returns the name of the last node of the given path
|
153 | * @param {string} path
|
154 | * @returns {string|null}
|
155 | */
|
156 | static getNodeName(path: string): string | null;
|
157 | /**
|
158 | * Returns the subpath of the targetPath relative to the rootPath,
|
159 | * or the targetPath if the rootPath is not a root of the targetPath.
|
160 | *
|
161 | * @param targetPath
|
162 | * @param rootPath
|
163 | * @returns {*}
|
164 | */
|
165 | static subpath(targetPath?: string, rootPath?: string): string;
|
166 | /**
|
167 | * Returns an array of segments of the path, split by the custom set of delimitators passed as an array.
|
168 | *
|
169 | * @param {string} path
|
170 | * @param {array} delimitators
|
171 | * @returns {*}
|
172 | */
|
173 | static splitByDelimitators(path: string, delimitators: string[]): string[];
|
174 | /**
|
175 | * Returns an JCR path based on pagePath and dataPath
|
176 | *
|
177 | * @param pagePath path to the page
|
178 | * @param dataPath path to the item on the page
|
179 | * @returns {string}
|
180 | */
|
181 | static _getJCRPath(pagePath: string, dataPath: string): string;
|
182 | /**
|
183 | * Returns object containing pagePath (path to a page) and, if exists, itemPath (path to the item on that page)
|
184 | * from the passed path
|
185 | *
|
186 | * @param {string} path
|
187 | * @returns {{pagePath}}
|
188 | */
|
189 | static splitPageContentPaths(path: string): {
|
190 | itemPath?: string;
|
191 | pagePath: string;
|
192 | } | undefined;
|
193 | /**
|
194 | * Returns path that is no longer prefixed nor suffixed by the set of strings passed as an array
|
195 | *
|
196 | * @param path
|
197 | * @param {array} strings
|
198 | * @returns {*}
|
199 | */
|
200 | static trimStrings(path: string, strings: string[]): string;
|
201 | static _getStartStrings(path: string, strings: string[]): string;
|
202 | }
|
203 | //# sourceMappingURL=PathUtils.d.ts.map |
\ | No newline at end of file |