@helpers4/url 2.0.0-alpha.3 → 2.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -1,8 +1,414 @@
1
- export declare function withTrailingSlash(url: string): string /** * Adds a trailing slash `/` to the given URL if it is not already present. * * This function is useful for ensuring that URLs are properly formatted * with a trailing slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withTrailingSlash * * @example * ```ts * withTrailingSlash('') // => '/' * withTrailingSlash('no/slash') // => 'no/slash/' * withTrailingSlash('already/has/slash/') // => 'already/has/slash/' * withTrailingSlash(undefined) // => undefined * withTrailingSlash(null) // => null * ``` */ export function withTrailingSlash(url: undefined): undefined /** * Adds a trailing slash `/` to the given URL if it is not already present. * * This function is useful for ensuring that URLs are properly formatted * with a trailing slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withTrailingSlash * * @example * ```ts * withTrailingSlash('') // => '/' * withTrailingSlash('no/slash') // => 'no/slash/' * withTrailingSlash('already/has/slash/') // => 'already/has/slash/' * withTrailingSlash(undefined) // => undefined * withTrailingSlash(null) // => null * ``` */ export function withTrailingSlash(url: null): null /** * Adds a trailing slash `/` to the given URL if it is not already present. * * This function is useful for ensuring that URLs are properly formatted * with a trailing slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withTrailingSlash * * @example * ```ts * withTrailingSlash('') // => '/' * withTrailingSlash('no/slash') // => 'no/slash/' * withTrailingSlash('already/has/slash/') // => 'already/has/slash/' * withTrailingSlash(undefined) // => undefined * withTrailingSlash(null) // => null * ``` */ export function withTrailingSlash( url: string | undefined | null, ): string | undefined | null;
2
- export declare function withoutLeadingSlash(url: string): string /** * Removes the leading slash `/` from the given URL if it is present. * * This function is useful for ensuring that URLs are properly formatted * without a leading slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withoutLeadingSlash * * @example * ```ts * withoutLeadingSlash('') // => '' * withoutLeadingSlash('/') // => '' * withoutLeadingSlash('/no/slash') // => 'no/slash' * withoutLeadingSlash('already/has/slash') // => 'already/has/slash' * withoutLeadingSlash(undefined) // => undefined * withoutLeadingSlash(null) // => null * ``` */ export function withoutLeadingSlash(url: undefined): undefined /** * Removes the leading slash `/` from the given URL if it is present. * * This function is useful for ensuring that URLs are properly formatted * without a leading slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withoutLeadingSlash * * @example * ```ts * withoutLeadingSlash('') // => '' * withoutLeadingSlash('/') // => '' * withoutLeadingSlash('/no/slash') // => 'no/slash' * withoutLeadingSlash('already/has/slash') // => 'already/has/slash' * withoutLeadingSlash(undefined) // => undefined * withoutLeadingSlash(null) // => null * ``` */ export function withoutLeadingSlash(url: null): null /** * Removes the leading slash `/` from the given URL if it is present. * * This function is useful for ensuring that URLs are properly formatted * without a leading slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withoutLeadingSlash * * @example * ```ts * withoutLeadingSlash('') // => '' * withoutLeadingSlash('/') // => '' * withoutLeadingSlash('/no/slash') // => 'no/slash' * withoutLeadingSlash('already/has/slash') // => 'already/has/slash' * withoutLeadingSlash(undefined) // => undefined * withoutLeadingSlash(null) // => null * ``` */ export function withoutLeadingSlash( url: string | undefined | null, ): string | undefined | null;
3
- export declare function cleanPath(url: string | undefined | null,): string | undefined | null;
4
- export declare function relativeURLToAbsolute(relativeUrl: string): string;
5
- export declare function withLeadingSlash(url: string): string /** * Adds a leading slash `/` to the given URL if it is not already present. * * This function is useful for ensuring that URLs are properly formatted * with a leading slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withLeadingSlash * * @example * ```ts * withLeadingSlash('') // => '/' * withLeadingSlash('no/slash') // => '/no/slash' * withLeadingSlash('/already/has/slash') // => '/already/has/slash' * withLeadingSlash(undefined) // => undefined * withLeadingSlash(null) // => null * ``` */ export function withLeadingSlash(url: undefined): undefined /** * Adds a leading slash `/` to the given URL if it is not already present. * * This function is useful for ensuring that URLs are properly formatted * with a leading slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withLeadingSlash * * @example * ```ts * withLeadingSlash('') // => '/' * withLeadingSlash('no/slash') // => '/no/slash' * withLeadingSlash('/already/has/slash') // => '/already/has/slash' * withLeadingSlash(undefined) // => undefined * withLeadingSlash(null) // => null * ``` */ export function withLeadingSlash(url: null): null /** * Adds a leading slash `/` to the given URL if it is not already present. * * This function is useful for ensuring that URLs are properly formatted * with a leading slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withLeadingSlash * * @example * ```ts * withLeadingSlash('') // => '/' * withLeadingSlash('no/slash') // => '/no/slash' * withLeadingSlash('/already/has/slash') // => '/already/has/slash' * withLeadingSlash(undefined) // => undefined * withLeadingSlash(null) // => null * ``` */ export function withLeadingSlash( url: string | undefined | null, ): string | undefined | null;
6
- export declare function extractPureURI(url: string): string; export function extractPureURI(url: undefined): undefined; export function extractPureURI(url: null): null; export function extractPureURI(url: string | undefined | null): string | undefined | null;
7
- export declare function onlyPath(url: string): string /** * Extract only the path from an URI with optional query and fragments. * * For example, all these parameters will return `/path`: * - `/path` * - `/path?query=thing` * - `/path#fragment` * - `/path?query=thing#fragment` * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @example * ```ts * onlyPath('/path') // => '/path' * onlyPath('/path?query=thing') // => '/path' * onlyPath('/path#fragment') // => '/path' * onlyPath('/path?query=thing#fragment') // => '/path' * onlyPath(undefined) // => undefined * onlyPath(null) // => null * ``` */ export function onlyPath(url: null): null /** * Extract only the path from an URI with optional query and fragments. * * For example, all these parameters will return `/path`: * - `/path` * - `/path?query=thing` * - `/path#fragment` * - `/path?query=thing#fragment` * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @example * ```ts * onlyPath('/path') // => '/path' * onlyPath('/path?query=thing') // => '/path' * onlyPath('/path#fragment') // => '/path' * onlyPath('/path?query=thing#fragment') // => '/path' * onlyPath(undefined) // => undefined * onlyPath(null) // => null * ``` */ export function onlyPath(url: undefined): undefined /** * Extract only the path from an URI with optional query and fragments. * * For example, all these parameters will return `/path`: * - `/path` * - `/path?query=thing` * - `/path#fragment` * - `/path?query=thing#fragment` * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @example * ```ts * onlyPath('/path') // => '/path' * onlyPath('/path?query=thing') // => '/path' * onlyPath('/path#fragment') // => '/path' * onlyPath('/path?query=thing#fragment') // => '/path' * onlyPath(undefined) // => undefined * onlyPath(null) // => null * ``` */ export function onlyPath( url: string | undefined | null, ): string | undefined | null;
8
- export declare function withoutTrailingSlash(url: string): string /** * Removes the trailing slash `/` from the given URL if it is present. * * This function is useful for ensuring that URLs are properly formatted * without a trailing slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withoutTrailingSlash * * @example * ```ts * withoutTrailingSlash('') // => '' * withoutTrailingSlash('/') // => '' * withoutTrailingSlash('no/slash/') // => 'no/slash' * withoutTrailingSlash('already/has/slash') // => 'already/has/slash' * withoutTrailingSlash(undefined) // => undefined * withoutTrailingSlash(null) // => null * ``` */ export function withoutTrailingSlash(url: undefined): undefined /** * Removes the trailing slash `/` from the given URL if it is present. * * This function is useful for ensuring that URLs are properly formatted * without a trailing slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withoutTrailingSlash * * @example * ```ts * withoutTrailingSlash('') // => '' * withoutTrailingSlash('/') // => '' * withoutTrailingSlash('no/slash/') // => 'no/slash' * withoutTrailingSlash('already/has/slash') // => 'already/has/slash' * withoutTrailingSlash(undefined) // => undefined * withoutTrailingSlash(null) // => null * ``` */ export function withoutTrailingSlash(url: null): null /** * Removes the trailing slash `/` from the given URL if it is present. * * This function is useful for ensuring that URLs are properly formatted * without a trailing slash, which is often required in web development for * consistency and to avoid issues with relative paths. * * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`. * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`. * * @see https://radashi.js.org/reference/url/withoutTrailingSlash * * @example * ```ts * withoutTrailingSlash('') // => '' * withoutTrailingSlash('/') // => '' * withoutTrailingSlash('no/slash/') // => 'no/slash' * withoutTrailingSlash('already/has/slash') // => 'already/has/slash' * withoutTrailingSlash(undefined) // => undefined * withoutTrailingSlash(null) // => null * ``` */ export function withoutTrailingSlash( url: string | undefined | null, ): string | undefined | null;
1
+ /**
2
+ * This file is part of helpers4.
3
+ * Copyright (C) 2025 baxyz
4
+ * SPDX-License-Identifier: LGPL-3.0-or-later
5
+ */
6
+ /**
7
+ * Clean an URL by removing duplicate slashes.
8
+ * The protocol part of the URL is not modified.
9
+ *
10
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
11
+ * @returns The cleaned URL string, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * cleanPath('/path//to///resource') // => '/path/to/resource'
16
+ * cleanPath('http://example.com//path//to///resource') // => 'http://example.com/path/to/resource'
17
+ * cleanPath(undefined) // => undefined
18
+ * cleanPath(null) // => null
19
+ * ```
20
+ */
21
+ declare function cleanPath(url: string | undefined | null): string | undefined | null;
22
+
23
+ /**
24
+ * This file is part of helpers4.
25
+ * Copyright (C) 2025 baxyz
26
+ * SPDX-License-Identifier: LGPL-3.0-or-later
27
+ */
28
+ /**
29
+ * Extracts the pure URI from a URL by removing query parameters and fragments.
30
+ *
31
+ * @param url - The URL string to process
32
+ * @returns The URI without query parameters and fragments, or the original value if undefined/null
33
+ */
34
+ declare function extractPureURI(url: string): string;
35
+ declare function extractPureURI(url: undefined): undefined;
36
+ declare function extractPureURI(url: null): null;
37
+
38
+ /**
39
+ * This file is part of helpers4.
40
+ * Copyright (C) 2025 baxyz
41
+ * SPDX-License-Identifier: LGPL-3.0-or-later
42
+ */
43
+ /**
44
+ * Extract only the path from an URI with optional query and fragments.
45
+ *
46
+ * For example, all these parameters will return `/path`:
47
+ * - `/path`
48
+ * - `/path?query=thing`
49
+ * - `/path#fragment`
50
+ * - `/path?query=thing#fragment`
51
+ *
52
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
53
+ * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * onlyPath('/path') // => '/path'
58
+ * onlyPath('/path?query=thing') // => '/path'
59
+ * onlyPath('/path#fragment') // => '/path'
60
+ * onlyPath('/path?query=thing#fragment') // => '/path'
61
+ * onlyPath(undefined) // => undefined
62
+ * onlyPath(null) // => null
63
+ * ```
64
+ */
65
+ declare function onlyPath(url: string): string;
66
+ /**
67
+ * Extract only the path from an URI with optional query and fragments.
68
+ *
69
+ * For example, all these parameters will return `/path`:
70
+ * - `/path`
71
+ * - `/path?query=thing`
72
+ * - `/path#fragment`
73
+ * - `/path?query=thing#fragment`
74
+ *
75
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
76
+ * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * onlyPath('/path') // => '/path'
81
+ * onlyPath('/path?query=thing') // => '/path'
82
+ * onlyPath('/path#fragment') // => '/path'
83
+ * onlyPath('/path?query=thing#fragment') // => '/path'
84
+ * onlyPath(undefined) // => undefined
85
+ * onlyPath(null) // => null
86
+ * ```
87
+ */
88
+ declare function onlyPath(url: null): null;
89
+ /**
90
+ * Extract only the path from an URI with optional query and fragments.
91
+ *
92
+ * For example, all these parameters will return `/path`:
93
+ * - `/path`
94
+ * - `/path?query=thing`
95
+ * - `/path#fragment`
96
+ * - `/path?query=thing#fragment`
97
+ *
98
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
99
+ * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * onlyPath('/path') // => '/path'
104
+ * onlyPath('/path?query=thing') // => '/path'
105
+ * onlyPath('/path#fragment') // => '/path'
106
+ * onlyPath('/path?query=thing#fragment') // => '/path'
107
+ * onlyPath(undefined) // => undefined
108
+ * onlyPath(null) // => null
109
+ * ```
110
+ */
111
+ declare function onlyPath(url: undefined): undefined;
112
+
113
+ /**
114
+ * This file is part of helpers4.
115
+ * Copyright (C) 2025 baxyz
116
+ * SPDX-License-Identifier: LGPL-3.0-or-later
117
+ */
118
+ declare function relativeURLToAbsolute(relativeUrl: string): string;
119
+
120
+ /**
121
+ * This file is part of helpers4.
122
+ * Copyright (C) 2025 baxyz
123
+ * SPDX-License-Identifier: LGPL-3.0-or-later
124
+ */
125
+ /**
126
+ * Adds a leading slash `/` to the given URL if it is not already present.
127
+ *
128
+ * This function is useful for ensuring that URLs are properly formatted
129
+ * with a leading slash, which is often required in web development for
130
+ * consistency and to avoid issues with relative paths.
131
+ *
132
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
133
+ * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
134
+ *
135
+ * @see https://radashi.js.org/reference/url/withLeadingSlash
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * withLeadingSlash('') // => '/'
140
+ * withLeadingSlash('no/slash') // => '/no/slash'
141
+ * withLeadingSlash('/already/has/slash') // => '/already/has/slash'
142
+ * withLeadingSlash(undefined) // => undefined
143
+ * withLeadingSlash(null) // => null
144
+ * ```
145
+ */
146
+ declare function withLeadingSlash(url: string): string;
147
+ /**
148
+ * Adds a leading slash `/` to the given URL if it is not already present.
149
+ *
150
+ * This function is useful for ensuring that URLs are properly formatted
151
+ * with a leading slash, which is often required in web development for
152
+ * consistency and to avoid issues with relative paths.
153
+ *
154
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
155
+ * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
156
+ *
157
+ * @see https://radashi.js.org/reference/url/withLeadingSlash
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * withLeadingSlash('') // => '/'
162
+ * withLeadingSlash('no/slash') // => '/no/slash'
163
+ * withLeadingSlash('/already/has/slash') // => '/already/has/slash'
164
+ * withLeadingSlash(undefined) // => undefined
165
+ * withLeadingSlash(null) // => null
166
+ * ```
167
+ */
168
+ declare function withLeadingSlash(url: undefined): undefined;
169
+ /**
170
+ * Adds a leading slash `/` to the given URL if it is not already present.
171
+ *
172
+ * This function is useful for ensuring that URLs are properly formatted
173
+ * with a leading slash, which is often required in web development for
174
+ * consistency and to avoid issues with relative paths.
175
+ *
176
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
177
+ * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
178
+ *
179
+ * @see https://radashi.js.org/reference/url/withLeadingSlash
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * withLeadingSlash('') // => '/'
184
+ * withLeadingSlash('no/slash') // => '/no/slash'
185
+ * withLeadingSlash('/already/has/slash') // => '/already/has/slash'
186
+ * withLeadingSlash(undefined) // => undefined
187
+ * withLeadingSlash(null) // => null
188
+ * ```
189
+ */
190
+ declare function withLeadingSlash(url: null): null;
191
+
192
+ /**
193
+ * This file is part of helpers4.
194
+ * Copyright (C) 2025 baxyz
195
+ * SPDX-License-Identifier: LGPL-3.0-or-later
196
+ */
197
+ /**
198
+ * Adds a trailing slash `/` to the given URL if it is not already present.
199
+ *
200
+ * This function is useful for ensuring that URLs are properly formatted
201
+ * with a trailing slash, which is often required in web development for
202
+ * consistency and to avoid issues with relative paths.
203
+ *
204
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
205
+ * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
206
+ *
207
+ * @see https://radashi.js.org/reference/url/withTrailingSlash
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * withTrailingSlash('') // => '/'
212
+ * withTrailingSlash('no/slash') // => 'no/slash/'
213
+ * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'
214
+ * withTrailingSlash(undefined) // => undefined
215
+ * withTrailingSlash(null) // => null
216
+ * ```
217
+ */
218
+ declare function withTrailingSlash(url: string): string;
219
+ /**
220
+ * Adds a trailing slash `/` to the given URL if it is not already present.
221
+ *
222
+ * This function is useful for ensuring that URLs are properly formatted
223
+ * with a trailing slash, which is often required in web development for
224
+ * consistency and to avoid issues with relative paths.
225
+ *
226
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
227
+ * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
228
+ *
229
+ * @see https://radashi.js.org/reference/url/withTrailingSlash
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * withTrailingSlash('') // => '/'
234
+ * withTrailingSlash('no/slash') // => 'no/slash/'
235
+ * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'
236
+ * withTrailingSlash(undefined) // => undefined
237
+ * withTrailingSlash(null) // => null
238
+ * ```
239
+ */
240
+ declare function withTrailingSlash(url: undefined): undefined;
241
+ /**
242
+ * Adds a trailing slash `/` to the given URL if it is not already present.
243
+ *
244
+ * This function is useful for ensuring that URLs are properly formatted
245
+ * with a trailing slash, which is often required in web development for
246
+ * consistency and to avoid issues with relative paths.
247
+ *
248
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
249
+ * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
250
+ *
251
+ * @see https://radashi.js.org/reference/url/withTrailingSlash
252
+ *
253
+ * @example
254
+ * ```ts
255
+ * withTrailingSlash('') // => '/'
256
+ * withTrailingSlash('no/slash') // => 'no/slash/'
257
+ * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'
258
+ * withTrailingSlash(undefined) // => undefined
259
+ * withTrailingSlash(null) // => null
260
+ * ```
261
+ */
262
+ declare function withTrailingSlash(url: null): null;
263
+
264
+ /**
265
+ * This file is part of helpers4.
266
+ * Copyright (C) 2025 baxyz
267
+ * SPDX-License-Identifier: LGPL-3.0-or-later
268
+ */
269
+ /**
270
+ * Removes the leading slash `/` from the given URL if it is present.
271
+ *
272
+ * This function is useful for ensuring that URLs are properly formatted
273
+ * without a leading slash, which is often required in web development for
274
+ * consistency and to avoid issues with relative paths.
275
+ *
276
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
277
+ * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
278
+ *
279
+ * @see https://radashi.js.org/reference/url/withoutLeadingSlash
280
+ *
281
+ * @example
282
+ * ```ts
283
+ * withoutLeadingSlash('') // => ''
284
+ * withoutLeadingSlash('/') // => ''
285
+ * withoutLeadingSlash('/no/slash') // => 'no/slash'
286
+ * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'
287
+ * withoutLeadingSlash(undefined) // => undefined
288
+ * withoutLeadingSlash(null) // => null
289
+ * ```
290
+ */
291
+ declare function withoutLeadingSlash(url: string): string;
292
+ /**
293
+ * Removes the leading slash `/` from the given URL if it is present.
294
+ *
295
+ * This function is useful for ensuring that URLs are properly formatted
296
+ * without a leading slash, which is often required in web development for
297
+ * consistency and to avoid issues with relative paths.
298
+ *
299
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
300
+ * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
301
+ *
302
+ * @see https://radashi.js.org/reference/url/withoutLeadingSlash
303
+ *
304
+ * @example
305
+ * ```ts
306
+ * withoutLeadingSlash('') // => ''
307
+ * withoutLeadingSlash('/') // => ''
308
+ * withoutLeadingSlash('/no/slash') // => 'no/slash'
309
+ * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'
310
+ * withoutLeadingSlash(undefined) // => undefined
311
+ * withoutLeadingSlash(null) // => null
312
+ * ```
313
+ */
314
+ declare function withoutLeadingSlash(url: undefined): undefined;
315
+ /**
316
+ * Removes the leading slash `/` from the given URL if it is present.
317
+ *
318
+ * This function is useful for ensuring that URLs are properly formatted
319
+ * without a leading slash, which is often required in web development for
320
+ * consistency and to avoid issues with relative paths.
321
+ *
322
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
323
+ * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
324
+ *
325
+ * @see https://radashi.js.org/reference/url/withoutLeadingSlash
326
+ *
327
+ * @example
328
+ * ```ts
329
+ * withoutLeadingSlash('') // => ''
330
+ * withoutLeadingSlash('/') // => ''
331
+ * withoutLeadingSlash('/no/slash') // => 'no/slash'
332
+ * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'
333
+ * withoutLeadingSlash(undefined) // => undefined
334
+ * withoutLeadingSlash(null) // => null
335
+ * ```
336
+ */
337
+ declare function withoutLeadingSlash(url: null): null;
338
+
339
+ /**
340
+ * This file is part of helpers4.
341
+ * Copyright (C) 2025 baxyz
342
+ * SPDX-License-Identifier: LGPL-3.0-or-later
343
+ */
344
+ /**
345
+ * Removes the trailing slash `/` from the given URL if it is present.
346
+ *
347
+ * This function is useful for ensuring that URLs are properly formatted
348
+ * without a trailing slash, which is often required in web development for
349
+ * consistency and to avoid issues with relative paths.
350
+ *
351
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
352
+ * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
353
+ *
354
+ * @see https://radashi.js.org/reference/url/withoutTrailingSlash
355
+ *
356
+ * @example
357
+ * ```ts
358
+ * withoutTrailingSlash('') // => ''
359
+ * withoutTrailingSlash('/') // => ''
360
+ * withoutTrailingSlash('no/slash/') // => 'no/slash'
361
+ * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'
362
+ * withoutTrailingSlash(undefined) // => undefined
363
+ * withoutTrailingSlash(null) // => null
364
+ * ```
365
+ */
366
+ declare function withoutTrailingSlash(url: string): string;
367
+ /**
368
+ * Removes the trailing slash `/` from the given URL if it is present.
369
+ *
370
+ * This function is useful for ensuring that URLs are properly formatted
371
+ * without a trailing slash, which is often required in web development for
372
+ * consistency and to avoid issues with relative paths.
373
+ *
374
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
375
+ * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
376
+ *
377
+ * @see https://radashi.js.org/reference/url/withoutTrailingSlash
378
+ *
379
+ * @example
380
+ * ```ts
381
+ * withoutTrailingSlash('') // => ''
382
+ * withoutTrailingSlash('/') // => ''
383
+ * withoutTrailingSlash('no/slash/') // => 'no/slash'
384
+ * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'
385
+ * withoutTrailingSlash(undefined) // => undefined
386
+ * withoutTrailingSlash(null) // => null
387
+ * ```
388
+ */
389
+ declare function withoutTrailingSlash(url: undefined): undefined;
390
+ /**
391
+ * Removes the trailing slash `/` from the given URL if it is present.
392
+ *
393
+ * This function is useful for ensuring that URLs are properly formatted
394
+ * without a trailing slash, which is often required in web development for
395
+ * consistency and to avoid issues with relative paths.
396
+ *
397
+ * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.
398
+ * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.
399
+ *
400
+ * @see https://radashi.js.org/reference/url/withoutTrailingSlash
401
+ *
402
+ * @example
403
+ * ```ts
404
+ * withoutTrailingSlash('') // => ''
405
+ * withoutTrailingSlash('/') // => ''
406
+ * withoutTrailingSlash('no/slash/') // => 'no/slash'
407
+ * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'
408
+ * withoutTrailingSlash(undefined) // => undefined
409
+ * withoutTrailingSlash(null) // => null
410
+ * ```
411
+ */
412
+ declare function withoutTrailingSlash(url: null): null;
413
+
414
+ export { cleanPath, extractPureURI, onlyPath, relativeURLToAbsolute, withLeadingSlash, withTrailingSlash, withoutLeadingSlash, withoutTrailingSlash };