@helpers4/url 1.0.1 → 2.0.0-alpha.2

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/LICENSE.md CHANGED
@@ -61,7 +61,7 @@ modification follow.
61
61
 
62
62
  ### TERMS AND CONDITIONS
63
63
 
64
- #### 0. Definitions.
64
+ #### 0. Definitions
65
65
 
66
66
  "This License" refers to version 3 of the GNU Affero General Public
67
67
  License.
@@ -102,7 +102,7 @@ work under this License, and how to view a copy of this License. If
102
102
  the interface presents a list of user commands or options, such as a
103
103
  menu, a prominent item in the list meets this criterion.
104
104
 
105
- #### 1. Source Code.
105
+ #### 1. Source Code
106
106
 
107
107
  The "source code" for a work means the preferred form of the work for
108
108
  making modifications to it. "Object code" means any non-source form of
@@ -143,7 +143,7 @@ regenerate automatically from other parts of the Corresponding Source.
143
143
  The Corresponding Source for a work in source code form is that same
144
144
  work.
145
145
 
146
- #### 2. Basic Permissions.
146
+ #### 2. Basic Permissions
147
147
 
148
148
  All rights granted under this License are granted for the term of
149
149
  copyright on the Program, and are irrevocable provided the stated
@@ -168,7 +168,7 @@ Conveying under any other circumstances is permitted solely under the
168
168
  conditions stated below. Sublicensing is not allowed; section 10 makes
169
169
  it unnecessary.
170
170
 
171
- #### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
171
+ #### 3. Protecting Users' Legal Rights From Anti-Circumvention Law
172
172
 
173
173
  No covered work shall be deemed part of an effective technological
174
174
  measure under any applicable law fulfilling obligations under article
@@ -184,7 +184,7 @@ operation or modification of the work as a means of enforcing, against
184
184
  the work's users, your or third parties' legal rights to forbid
185
185
  circumvention of technological measures.
186
186
 
187
- #### 4. Conveying Verbatim Copies.
187
+ #### 4. Conveying Verbatim Copies
188
188
 
189
189
  You may convey verbatim copies of the Program's source code as you
190
190
  receive it, in any medium, provided that you conspicuously and
@@ -197,30 +197,30 @@ recipients a copy of this License along with the Program.
197
197
  You may charge any price or no price for each copy that you convey,
198
198
  and you may offer support or warranty protection for a fee.
199
199
 
200
- #### 5. Conveying Modified Source Versions.
200
+ #### 5. Conveying Modified Source Versions
201
201
 
202
202
  You may convey a work based on the Program, or the modifications to
203
203
  produce it from the Program, in the form of source code under the
204
204
  terms of section 4, provided that you also meet all of these
205
205
  conditions:
206
206
 
207
- - a) The work must carry prominent notices stating that you modified
208
- it, and giving a relevant date.
209
- - b) The work must carry prominent notices stating that it is
210
- released under this License and any conditions added under
211
- section 7. This requirement modifies the requirement in section 4
212
- to "keep intact all notices".
213
- - c) You must license the entire work, as a whole, under this
214
- License to anyone who comes into possession of a copy. This
215
- License will therefore apply, along with any applicable section 7
216
- additional terms, to the whole of the work, and all its parts,
217
- regardless of how they are packaged. This License gives no
218
- permission to license the work in any other way, but it does not
219
- invalidate such permission if you have separately received it.
220
- - d) If the work has interactive user interfaces, each must display
221
- Appropriate Legal Notices; however, if the Program has interactive
222
- interfaces that do not display Appropriate Legal Notices, your
223
- work need not make them do so.
207
+ - a) The work must carry prominent notices stating that you modified
208
+ it, and giving a relevant date.
209
+ - b) The work must carry prominent notices stating that it is
210
+ released under this License and any conditions added under
211
+ section 7. This requirement modifies the requirement in section 4
212
+ to "keep intact all notices".
213
+ - c) You must license the entire work, as a whole, under this
214
+ License to anyone who comes into possession of a copy. This
215
+ License will therefore apply, along with any applicable section 7
216
+ additional terms, to the whole of the work, and all its parts,
217
+ regardless of how they are packaged. This License gives no
218
+ permission to license the work in any other way, but it does not
219
+ invalidate such permission if you have separately received it.
220
+ - d) If the work has interactive user interfaces, each must display
221
+ Appropriate Legal Notices; however, if the Program has interactive
222
+ interfaces that do not display Appropriate Legal Notices, your
223
+ work need not make them do so.
224
224
 
225
225
  A compilation of a covered work with other separate and independent
226
226
  works, which are not by their nature extensions of the covered work,
@@ -232,49 +232,49 @@ beyond what the individual works permit. Inclusion of a covered work
232
232
  in an aggregate does not cause this License to apply to the other
233
233
  parts of the aggregate.
234
234
 
235
- #### 6. Conveying Non-Source Forms.
235
+ #### 6. Conveying Non-Source Forms
236
236
 
237
237
  You may convey a covered work in object code form under the terms of
238
238
  sections 4 and 5, provided that you also convey the machine-readable
239
239
  Corresponding Source under the terms of this License, in one of these
240
240
  ways:
241
241
 
242
- - a) Convey the object code in, or embodied in, a physical product
243
- (including a physical distribution medium), accompanied by the
244
- Corresponding Source fixed on a durable physical medium
245
- customarily used for software interchange.
246
- - b) Convey the object code in, or embodied in, a physical product
247
- (including a physical distribution medium), accompanied by a
248
- written offer, valid for at least three years and valid for as
249
- long as you offer spare parts or customer support for that product
250
- model, to give anyone who possesses the object code either (1) a
251
- copy of the Corresponding Source for all the software in the
252
- product that is covered by this License, on a durable physical
253
- medium customarily used for software interchange, for a price no
254
- more than your reasonable cost of physically performing this
255
- conveying of source, or (2) access to copy the Corresponding
256
- Source from a network server at no charge.
257
- - c) Convey individual copies of the object code with a copy of the
258
- written offer to provide the Corresponding Source. This
259
- alternative is allowed only occasionally and noncommercially, and
260
- only if you received the object code with such an offer, in accord
261
- with subsection 6b.
262
- - d) Convey the object code by offering access from a designated
263
- place (gratis or for a charge), and offer equivalent access to the
264
- Corresponding Source in the same way through the same place at no
265
- further charge. You need not require recipients to copy the
266
- Corresponding Source along with the object code. If the place to
267
- copy the object code is a network server, the Corresponding Source
268
- may be on a different server (operated by you or a third party)
269
- that supports equivalent copying facilities, provided you maintain
270
- clear directions next to the object code saying where to find the
271
- Corresponding Source. Regardless of what server hosts the
272
- Corresponding Source, you remain obligated to ensure that it is
273
- available for as long as needed to satisfy these requirements.
274
- - e) Convey the object code using peer-to-peer transmission,
275
- provided you inform other peers where the object code and
276
- Corresponding Source of the work are being offered to the general
277
- public at no charge under subsection 6d.
242
+ - a) Convey the object code in, or embodied in, a physical product
243
+ (including a physical distribution medium), accompanied by the
244
+ Corresponding Source fixed on a durable physical medium
245
+ customarily used for software interchange.
246
+ - b) Convey the object code in, or embodied in, a physical product
247
+ (including a physical distribution medium), accompanied by a
248
+ written offer, valid for at least three years and valid for as
249
+ long as you offer spare parts or customer support for that product
250
+ model, to give anyone who possesses the object code either (1) a
251
+ copy of the Corresponding Source for all the software in the
252
+ product that is covered by this License, on a durable physical
253
+ medium customarily used for software interchange, for a price no
254
+ more than your reasonable cost of physically performing this
255
+ conveying of source, or (2) access to copy the Corresponding
256
+ Source from a network server at no charge.
257
+ - c) Convey individual copies of the object code with a copy of the
258
+ written offer to provide the Corresponding Source. This
259
+ alternative is allowed only occasionally and noncommercially, and
260
+ only if you received the object code with such an offer, in accord
261
+ with subsection 6b.
262
+ - d) Convey the object code by offering access from a designated
263
+ place (gratis or for a charge), and offer equivalent access to the
264
+ Corresponding Source in the same way through the same place at no
265
+ further charge. You need not require recipients to copy the
266
+ Corresponding Source along with the object code. If the place to
267
+ copy the object code is a network server, the Corresponding Source
268
+ may be on a different server (operated by you or a third party)
269
+ that supports equivalent copying facilities, provided you maintain
270
+ clear directions next to the object code saying where to find the
271
+ Corresponding Source. Regardless of what server hosts the
272
+ Corresponding Source, you remain obligated to ensure that it is
273
+ available for as long as needed to satisfy these requirements.
274
+ - e) Convey the object code using peer-to-peer transmission,
275
+ provided you inform other peers where the object code and
276
+ Corresponding Source of the work are being offered to the general
277
+ public at no charge under subsection 6d.
278
278
 
279
279
  A separable portion of the object code, whose source code is excluded
280
280
  from the Corresponding Source as a System Library, need not be
@@ -328,7 +328,7 @@ documented (and with an implementation available to the public in
328
328
  source code form), and must require no special password or key for
329
329
  unpacking, reading or copying.
330
330
 
331
- #### 7. Additional Terms.
331
+ #### 7. Additional Terms
332
332
 
333
333
  "Additional permissions" are terms that supplement the terms of this
334
334
  License by making exceptions from one or more of its conditions.
@@ -350,23 +350,23 @@ Notwithstanding any other provision of this License, for material you
350
350
  add to a covered work, you may (if authorized by the copyright holders
351
351
  of that material) supplement the terms of this License with terms:
352
352
 
353
- - a) Disclaiming warranty or limiting liability differently from the
354
- terms of sections 15 and 16 of this License; or
355
- - b) Requiring preservation of specified reasonable legal notices or
356
- author attributions in that material or in the Appropriate Legal
357
- Notices displayed by works containing it; or
358
- - c) Prohibiting misrepresentation of the origin of that material,
359
- or requiring that modified versions of such material be marked in
360
- reasonable ways as different from the original version; or
361
- - d) Limiting the use for publicity purposes of names of licensors
362
- or authors of the material; or
363
- - e) Declining to grant rights under trademark law for use of some
364
- trade names, trademarks, or service marks; or
365
- - f) Requiring indemnification of licensors and authors of that
366
- material by anyone who conveys the material (or modified versions
367
- of it) with contractual assumptions of liability to the recipient,
368
- for any liability that these contractual assumptions directly
369
- impose on those licensors and authors.
353
+ - a) Disclaiming warranty or limiting liability differently from the
354
+ terms of sections 15 and 16 of this License; or
355
+ - b) Requiring preservation of specified reasonable legal notices or
356
+ author attributions in that material or in the Appropriate Legal
357
+ Notices displayed by works containing it; or
358
+ - c) Prohibiting misrepresentation of the origin of that material,
359
+ or requiring that modified versions of such material be marked in
360
+ reasonable ways as different from the original version; or
361
+ - d) Limiting the use for publicity purposes of names of licensors
362
+ or authors of the material; or
363
+ - e) Declining to grant rights under trademark law for use of some
364
+ trade names, trademarks, or service marks; or
365
+ - f) Requiring indemnification of licensors and authors of that
366
+ material by anyone who conveys the material (or modified versions
367
+ of it) with contractual assumptions of liability to the recipient,
368
+ for any liability that these contractual assumptions directly
369
+ impose on those licensors and authors.
370
370
 
371
371
  All other non-permissive additional terms are considered "further
372
372
  restrictions" within the meaning of section 10. If the Program as you
@@ -387,7 +387,7 @@ Additional terms, permissive or non-permissive, may be stated in the
387
387
  form of a separately written license, or stated as exceptions; the
388
388
  above requirements apply either way.
389
389
 
390
- #### 8. Termination.
390
+ #### 8. Termination
391
391
 
392
392
  You may not propagate or modify a covered work except as expressly
393
393
  provided under this License. Any attempt otherwise to propagate or
@@ -415,7 +415,7 @@ this License. If your rights have been terminated and not permanently
415
415
  reinstated, you do not qualify to receive new licenses for the same
416
416
  material under section 10.
417
417
 
418
- #### 9. Acceptance Not Required for Having Copies.
418
+ #### 9. Acceptance Not Required for Having Copies
419
419
 
420
420
  You are not required to accept this License in order to receive or run
421
421
  a copy of the Program. Ancillary propagation of a covered work
@@ -426,7 +426,7 @@ modify any covered work. These actions infringe copyright if you do
426
426
  not accept this License. Therefore, by modifying or propagating a
427
427
  covered work, you indicate your acceptance of this License to do so.
428
428
 
429
- #### 10. Automatic Licensing of Downstream Recipients.
429
+ #### 10. Automatic Licensing of Downstream Recipients
430
430
 
431
431
  Each time you convey a covered work, the recipient automatically
432
432
  receives a license from the original licensors, to run, modify and
@@ -451,7 +451,7 @@ rights granted under this License, and you may not initiate litigation
451
451
  any patent claim is infringed by making, using, selling, offering for
452
452
  sale, or importing the Program or any portion of it.
453
453
 
454
- #### 11. Patents.
454
+ #### 11. Patents
455
455
 
456
456
  A "contributor" is a copyright holder who authorizes use under this
457
457
  License of the Program or a work on which the Program is based. The
@@ -520,7 +520,7 @@ Nothing in this License shall be construed as excluding or limiting
520
520
  any implied license or other defenses to infringement that may
521
521
  otherwise be available to you under applicable patent law.
522
522
 
523
- #### 12. No Surrender of Others' Freedom.
523
+ #### 12. No Surrender of Others' Freedom
524
524
 
525
525
  If conditions are imposed on you (whether by court order, agreement or
526
526
  otherwise) that contradict the conditions of this License, they do not
@@ -533,7 +533,7 @@ from those to whom you convey the Program, the only way you could
533
533
  satisfy both those terms and this License would be to refrain entirely
534
534
  from conveying the Program.
535
535
 
536
- #### 13. Remote Network Interaction; Use with the GNU General Public License.
536
+ #### 13. Remote Network Interaction; Use with the GNU General Public License
537
537
 
538
538
  Notwithstanding any other provision of this License, if you modify the
539
539
  Program, your modified version must prominently offer all users
@@ -554,7 +554,7 @@ License will continue to apply to the part which is the covered work,
554
554
  but the work with which it is combined will remain governed by version
555
555
  3 of the GNU General Public License.
556
556
 
557
- #### 14. Revised Versions of this License.
557
+ #### 14. Revised Versions of this License
558
558
 
559
559
  The Free Software Foundation may publish revised and/or new versions
560
560
  of the GNU Affero General Public License from time to time. Such new
@@ -580,7 +580,7 @@ permissions. However, no additional obligations are imposed on any
580
580
  author or copyright holder as a result of your choosing to follow a
581
581
  later version.
582
582
 
583
- #### 15. Disclaimer of Warranty.
583
+ #### 15. Disclaimer of Warranty
584
584
 
585
585
  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
586
586
  APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
@@ -592,7 +592,7 @@ PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
592
592
  DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
593
593
  CORRECTION.
594
594
 
595
- #### 16. Limitation of Liability.
595
+ #### 16. Limitation of Liability
596
596
 
597
597
  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
598
598
  WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
@@ -604,7 +604,7 @@ LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
604
604
  TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
605
605
  PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
606
606
 
607
- #### 17. Interpretation of Sections 15 and 16.
607
+ #### 17. Interpretation of Sections 15 and 16
608
608
 
609
609
  If the disclaimer of warranty and limitation of liability provided
610
610
  above cannot be given local legal effect according to their terms,
package/README.md CHANGED
@@ -9,9 +9,62 @@ A set of helpers for working with URLs.
9
9
 
10
10
  ## Documentation
11
11
 
12
- [https://helpers4.github.io/url](https://helpers4.github.io/url)
12
+ [https://helpers4.js.org/url](https://helpers4.js.org/url)
13
+
14
+ <!-- AUTOMATIC-METHODS -->
15
+ - withTrailingSlash
16
+ - withoutLeadingSlash
17
+ - cleanPath
18
+ - relativeURLToAbsolute
19
+ - withLeadingSlash
20
+ - extractPureURI
21
+ - onlyPath
22
+ - withoutTrailingSlash
23
+ <!-- /AUTOMATIC-METHODS -->
13
24
 
14
25
  ## See
15
26
 
16
- - [@helpers4/string](https://www.npmjs.com/package/@helpers4/string)
17
- - [@helpers4/url](https://www.npmjs.com/package/@helpers4/url)
27
+ <!-- AUTOMATIC-SIBLINGS -->
28
+ - [array](../array)
29
+ - [date](../date)
30
+ - [function](../function)
31
+ - [number](../number)
32
+ - [object](../object)
33
+ - [observable](../observable)
34
+ - [promise](../promise)
35
+ - [string](../string)
36
+ - [type](../type)
37
+ - [version](../version)
38
+ <!-- /AUTOMATIC-SIBLINGS -->
39
+
40
+ ## All Available Packages
41
+
42
+ <!-- AUTOMATIC-CATEGORIES-TABLE -->
43
+ | Name | Package | Source Code | Description |
44
+ |------|---------|-------------|-------------|
45
+ | array | [@helpers4/array](https://www.npmjs.com/package/@helpers4/array) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/array) | Array manipulation utilities |
46
+ | date | [@helpers4/date](https://www.npmjs.com/package/@helpers4/date) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/date) | date utilities |
47
+ | function | [@helpers4/function](https://www.npmjs.com/package/@helpers4/function) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/function) | Function utilities and type guards |
48
+ | number | [@helpers4/number](https://www.npmjs.com/package/@helpers4/number) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/number) | number utilities |
49
+ | object | [@helpers4/object](https://www.npmjs.com/package/@helpers4/object) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/object) | Object manipulation utilities |
50
+ | observable | [@helpers4/observable](https://www.npmjs.com/package/@helpers4/observable) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/observable) | Observable utilities and combinators |
51
+ | promise | [@helpers4/promise](https://www.npmjs.com/package/@helpers4/promise) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/promise) | Promise utilities and error handling |
52
+ | string | [@helpers4/string](https://www.npmjs.com/package/@helpers4/string) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/string) | String manipulation and formatting utilities |
53
+ | type | [@helpers4/type](https://www.npmjs.com/package/@helpers4/type) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/type) | type utilities |
54
+ | url | [@helpers4/url](https://www.npmjs.com/package/@helpers4/url) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/url) | URL parsing and manipulation utilities |
55
+ | version | [@helpers4/version](https://www.npmjs.com/package/@helpers4/version) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/version) | Version string manipulation utilities |
56
+ <!-- /AUTOMATIC-CATEGORIES-TABLE -->
57
+
58
+ ## Contributors
59
+
60
+ <table>
61
+ <tr>
62
+ <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
63
+ <a href=https://github.com/baxyz>
64
+ <img src=https://avatars.githubusercontent.com/u/7852177?v=4 width="100;" alt=baxyz/>
65
+ <br />
66
+ <sub style="font-size:14px"><b>baxyz</b></sub>
67
+ </a>
68
+ </td>
69
+ </tr>
70
+ </table>
package/lib/index.d.ts ADDED
@@ -0,0 +1,8 @@
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;
package/lib/index.js ADDED
@@ -0,0 +1,79 @@
1
+ // helpers/url/withTrailingSlash.ts
2
+ function withTrailingSlash(url) {
3
+ if (url === undefined || url === null) {
4
+ return url;
5
+ }
6
+ return url[url.length - 1] === "/" ? url : url + "/";
7
+ }
8
+ // helpers/url/withoutLeadingSlash.ts
9
+ function withoutLeadingSlash(url) {
10
+ if (url === undefined || url === null) {
11
+ return url;
12
+ }
13
+ return url[0] === "/" ? url.slice(1) : url;
14
+ }
15
+ // helpers/url/cleanPath.ts
16
+ function cleanPath(url) {
17
+ if (url === undefined || url === null) {
18
+ return url;
19
+ }
20
+ return url.replace(/([^:]\/)\/+/g, "$1");
21
+ }
22
+ // helpers/url/withoutTrailingSlash.ts
23
+ function withoutTrailingSlash(url) {
24
+ if (url === undefined || url === null) {
25
+ return url;
26
+ }
27
+ return url[url.length - 1] === "/" ? url.slice(0, -1) : url;
28
+ }
29
+
30
+ // helpers/url/withLeadingSlash.ts
31
+ function withLeadingSlash(url) {
32
+ if (url === undefined || url === null) {
33
+ return url;
34
+ }
35
+ return url[0] === "/" ? url : "/" + url;
36
+ }
37
+
38
+ // helpers/url/relativeURLToAbsolute.ts
39
+ function relativeURLToAbsolute(relativeUrl) {
40
+ return withoutTrailingSlash(document.baseURI ?? window.location.origin) + cleanPath(withLeadingSlash(relativeUrl));
41
+ }
42
+ // helpers/url/extractPureURI.ts
43
+ function extractPureURI(url) {
44
+ if (url === undefined || url === null) {
45
+ return url;
46
+ }
47
+ const queryIndex = url.indexOf("?");
48
+ const fragmentIndex = url.indexOf("#");
49
+ let cutIndex = -1;
50
+ if (queryIndex !== -1 && fragmentIndex !== -1) {
51
+ cutIndex = Math.min(queryIndex, fragmentIndex);
52
+ } else if (queryIndex !== -1) {
53
+ cutIndex = queryIndex;
54
+ } else if (fragmentIndex !== -1) {
55
+ cutIndex = fragmentIndex;
56
+ }
57
+ if (cutIndex === -1) {
58
+ return url;
59
+ }
60
+ return url.substring(0, cutIndex);
61
+ }
62
+ // helpers/url/onlyPath.ts
63
+ function onlyPath(url) {
64
+ if (url === undefined || url === null) {
65
+ return url;
66
+ }
67
+ const [path] = url.split(/[?#]/);
68
+ return path;
69
+ }
70
+ export {
71
+ withoutTrailingSlash,
72
+ withoutLeadingSlash,
73
+ withTrailingSlash,
74
+ withLeadingSlash,
75
+ relativeURLToAbsolute,
76
+ onlyPath,
77
+ extractPureURI,
78
+ cleanPath
79
+ };
package/package.json CHANGED
@@ -1,112 +1,40 @@
1
1
  {
2
2
  "name": "@helpers4/url",
3
- "version": "1.0.1",
4
- "description": "A set of helpers in TS/JS, compatible with tree-shaking, which helps you to manipulate URLs.",
5
- "main": "build/main/index.js",
6
- "typings": "build/main/index.d.ts",
7
- "module": "build/module/index.js",
8
- "repository": "https://github.com/helpers4/url",
3
+ "version": "2.0.0-alpha.2",
4
+ "description": "A set of helpers in TS/JS, compatible with tree-shaking, for url.",
5
+ "author": "baxyz <baxy@etik.com>",
9
6
  "license": "AGPL-3.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/helpers4/helpers4.git"
10
+ },
11
+ "type": "module",
12
+ "main": "lib/index.js",
13
+ "types": "lib/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./lib/index.d.ts",
17
+ "import": "./lib/index.js"
18
+ }
19
+ },
10
20
  "keywords": [
11
- "helper",
12
- "string",
21
+ "helpers",
13
22
  "url",
14
- "typescript",
15
- "tree-shaking",
16
- "remove-ending-slash",
17
- "add-leading-slash",
18
- "extract-pure-uri"
23
+ "withTrailingSlash",
24
+ "withoutLeadingSlash",
25
+ "cleanPath",
26
+ "relativeURLToAbsolute",
27
+ "withLeadingSlash",
28
+ "extractPureURI",
29
+ "onlyPath",
30
+ "withoutTrailingSlash"
19
31
  ],
20
- "scripts": {
21
- "build": "run-p build:*",
22
- "build:main": "tsc -p tsconfig.json",
23
- "build:module": "tsc -p tsconfig.module.json",
24
- "fix": "run-s fix:*",
25
- "fix:prettier": "prettier \"src/**/*.ts\" --write",
26
- "fix:lint": "eslint src --ext .ts --fix",
27
- "test": "run-s build test:*",
28
- "test:lint": "eslint src --ext .ts",
29
- "test:prettier": "prettier \"src/**/*.ts\" --list-different",
30
- "test:spelling": "cspell \"{README.md,.github/*.md,src/**/*.ts}\"",
31
- "test:unit": "nyc --silent ava",
32
- "check-cli": "run-s test diff-integration-tests check-integration-tests",
33
- "check-integration-tests": "run-s check-integration-test:*",
34
- "diff-integration-tests": "mkdir -p diff && rm -rf diff/test && cp -r test diff/test && rm -rf diff/test/test-*/.git && cd diff && git init --quiet && git add -A && git commit --quiet --no-verify --allow-empty -m 'WIP' && echo '\\n\\nCommitted most recent integration test output in the \"diff\" directory. Review the changes with \"cd diff && git diff HEAD\" or your preferred git diff viewer.'",
35
- "watch:build": "tsc -p tsconfig.json -w",
36
- "watch:test": "nyc --silent ava --watch",
37
- "cov": "run-s build test:unit cov:html cov:lcov && open-cli coverage/index.html",
38
- "cov:html": "nyc report --reporter=html",
39
- "cov:lcov": "nyc report --reporter=lcov",
40
- "cov:send": "run-s cov:lcov && codecov",
41
- "cov:check": "nyc report && nyc check-coverage --lines 100 --functions 100 --branches 100",
42
- "doc": "run-s doc:html && open-cli build/docs/index.html",
43
- "doc:html": "typedoc src/index.ts --out build/docs",
44
- "doc:json": "typedoc src/index.ts --json build/docs/typedoc.json --pretty",
45
- "doc:publish": "gh-pages -m \"[ci skip] Updates\" -d build/docs",
46
- "version": "standard-version",
47
- "reset-hard": "git clean -dfx && git reset --hard && npm i",
48
- "prepare-release": "run-s reset-hard test cov:check doc:html version doc:publish"
49
- },
50
- "engines": {
51
- "node": ">=10"
52
- },
53
- "devDependencies": {
54
- "@ava/typescript": "^1.1.1",
55
- "@istanbuljs/nyc-config-typescript": "^1.0.1",
56
- "@typescript-eslint/eslint-plugin": "^4.0.1",
57
- "@typescript-eslint/parser": "^4.0.1",
58
- "ava": "^4.3.3",
59
- "codecov": "^3.5.0",
60
- "cspell": "^4.1.0",
61
- "cz-conventional-changelog": "^3.3.0",
62
- "eslint": "^7.8.0",
63
- "eslint-config-prettier": "^6.11.0",
64
- "eslint-plugin-eslint-comments": "^3.2.0",
65
- "eslint-plugin-functional": "^3.0.2",
66
- "eslint-plugin-import": "^2.22.0",
67
- "gh-pages": "^3.1.0",
68
- "npm-run-all": "^4.1.5",
69
- "nyc": "^15.1.0",
70
- "open-cli": "^7.0.1",
71
- "prettier": "^2.1.1",
72
- "standard-version": "^9.0.0",
73
- "ts-node": "^9.0.0",
74
- "typedoc": "^0.23.13",
75
- "typescript": "^4.0.2"
76
- },
77
32
  "files": [
78
- "build/main",
79
- "build/module",
80
- "!**/*.spec.*",
81
- "!**/*.json",
82
- "CHANGELOG.md",
33
+ "lib/index.js",
34
+ "lib/index.d.ts",
35
+ "lib/index.js.map",
83
36
  "LICENSE.md",
37
+ "package.json",
84
38
  "README.md"
85
- ],
86
- "ava": {
87
- "failFast": true,
88
- "timeout": "60s",
89
- "typescript": {
90
- "rewritePaths": {
91
- "src/": "build/main/"
92
- }
93
- },
94
- "files": [
95
- "!build/module/**"
96
- ]
97
- },
98
- "config": {
99
- "commitizen": {
100
- "path": "cz-conventional-changelog"
101
- }
102
- },
103
- "prettier": {
104
- "singleQuote": true
105
- },
106
- "nyc": {
107
- "extends": "@istanbuljs/nyc-config-typescript",
108
- "exclude": [
109
- "**/*.spec.js"
110
- ]
111
- }
112
- }
39
+ ]
40
+ }
package/CHANGELOG.md DELETED
@@ -1,7 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ### [1.0.1](https://github.com/helpers4/url/compare/v1.0.0...v1.0.1) (2022-09-03)
6
-
7
- ### 1.0.0 (2022-09-03)
@@ -1,66 +0,0 @@
1
- /**
2
- * Simple helper method that remove an ending slash `/` if present.
3
- *
4
- * ### Example (es module)
5
- * ```js
6
- * import { removeEndingSlash } from '@helpers4/url'
7
- * console.log(removeEndingSlash('https://www.google.com/'))
8
- * // => 'https://www.google.com'
9
- * ```
10
- *
11
- * ### Example (commonjs)
12
- * ```js
13
- * var removeEndingSlash = require('@helpers4/url').removeEndingSlash;
14
- * console.log(removeEndingSlash('https://www.google.com/'))
15
- * // => 'https://www.google.com'
16
- * ```
17
- *
18
- * @param url a valid URL
19
- */
20
- export declare function removeEndingSlash(url: string): string;
21
- /**
22
- * Simple helper method that add a leading slash `/` if not yet present.
23
- *
24
- * ### Example (es module)
25
- * ```js
26
- * import { addLeadingSlash } from '@helpers4/url'
27
- * console.log(addLeadingSlash('/your/path/with/leading/slash'))
28
- * // => 'your/path/with/leading/slash'
29
- * ```
30
- *
31
- * ### Example (commonjs)
32
- * ```js
33
- * var addLeadingSlash = require('@helpers4/url').addLeadingSlash;
34
- * console.log(addLeadingSlash('/your/path/with/leading/slash'))
35
- * // => 'your/path/with/leading/slash'
36
- * ```
37
- *
38
- * @param url a valid URL
39
- */
40
- export declare function addLeadingSlash(url: string): string;
41
- /**
42
- * Extract only the URI from a path with optional query and fragments.
43
- *
44
- * For example, all these parameters will returns `/path`:
45
- * - `/path`
46
- * - `/path?query=thing`
47
- * - `/path#fragment`
48
- * - `/path?query=thing#fragment`
49
- *
50
- * ### Example (es module)
51
- * ```js
52
- * import { extractPureURI } from '@helpers4/url'
53
- * console.log(extractPureURI('https://www.google.com/?q=search'))
54
- * // => 'https://www.google.com/'
55
- * ```
56
- *
57
- * ### Example (commonjs)
58
- * ```js
59
- * var extractPureURI = require('@helpers4/url').extractPureURI;
60
- * console.log(extractPureURI('https://www.google.com/?q=search'))
61
- * // => 'https://www.google.com/'
62
- * ```
63
- *
64
- * @param path a complete path without server part.
65
- */
66
- export declare function extractPureURI(path: string): string;
@@ -1,83 +0,0 @@
1
- "use strict";
2
- /*
3
- * This program is under the terms of the GNU Affero General Public License version 3
4
- * The full license information can be found in LICENSE in the root directory of this project.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.extractPureURI = exports.addLeadingSlash = exports.removeEndingSlash = void 0;
8
- /**
9
- * Simple helper method that remove an ending slash `/` if present.
10
- *
11
- * ### Example (es module)
12
- * ```js
13
- * import { removeEndingSlash } from '@helpers4/url'
14
- * console.log(removeEndingSlash('https://www.google.com/'))
15
- * // => 'https://www.google.com'
16
- * ```
17
- *
18
- * ### Example (commonjs)
19
- * ```js
20
- * var removeEndingSlash = require('@helpers4/url').removeEndingSlash;
21
- * console.log(removeEndingSlash('https://www.google.com/'))
22
- * // => 'https://www.google.com'
23
- * ```
24
- *
25
- * @param url a valid URL
26
- */
27
- function removeEndingSlash(url) {
28
- return url[url.length - 1] === '/' ? url.slice(0, -1) : url;
29
- }
30
- exports.removeEndingSlash = removeEndingSlash;
31
- /**
32
- * Simple helper method that add a leading slash `/` if not yet present.
33
- *
34
- * ### Example (es module)
35
- * ```js
36
- * import { addLeadingSlash } from '@helpers4/url'
37
- * console.log(addLeadingSlash('/your/path/with/leading/slash'))
38
- * // => 'your/path/with/leading/slash'
39
- * ```
40
- *
41
- * ### Example (commonjs)
42
- * ```js
43
- * var addLeadingSlash = require('@helpers4/url').addLeadingSlash;
44
- * console.log(addLeadingSlash('/your/path/with/leading/slash'))
45
- * // => 'your/path/with/leading/slash'
46
- * ```
47
- *
48
- * @param url a valid URL
49
- */
50
- function addLeadingSlash(url) {
51
- return url[0] === '/' ? url : '/' + url;
52
- }
53
- exports.addLeadingSlash = addLeadingSlash;
54
- /**
55
- * Extract only the URI from a path with optional query and fragments.
56
- *
57
- * For example, all these parameters will returns `/path`:
58
- * - `/path`
59
- * - `/path?query=thing`
60
- * - `/path#fragment`
61
- * - `/path?query=thing#fragment`
62
- *
63
- * ### Example (es module)
64
- * ```js
65
- * import { extractPureURI } from '@helpers4/url'
66
- * console.log(extractPureURI('https://www.google.com/?q=search'))
67
- * // => 'https://www.google.com/'
68
- * ```
69
- *
70
- * ### Example (commonjs)
71
- * ```js
72
- * var extractPureURI = require('@helpers4/url').extractPureURI;
73
- * console.log(extractPureURI('https://www.google.com/?q=search'))
74
- * // => 'https://www.google.com/'
75
- * ```
76
- *
77
- * @param path a complete path without server part.
78
- */
79
- function extractPureURI(path) {
80
- return path.split(/[?#]/)[0];
81
- }
82
- exports.extractPureURI = extractPureURI;
83
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXJsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2hlbHBlci91cmwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7R0FHRzs7O0FBRUg7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQWtCRztBQUNILFNBQWdCLGlCQUFpQixDQUFDLEdBQVc7SUFDM0MsT0FBTyxHQUFHLENBQUMsR0FBRyxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUMsS0FBSyxHQUFHLENBQUMsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsQ0FBQztBQUM5RCxDQUFDO0FBRkQsOENBRUM7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBa0JHO0FBQ0gsU0FBZ0IsZUFBZSxDQUFDLEdBQVc7SUFDekMsT0FBTyxHQUFHLENBQUMsQ0FBQyxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUM7QUFDMUMsQ0FBQztBQUZELDBDQUVDO0FBRUQ7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQXdCRztBQUNILFNBQWdCLGNBQWMsQ0FBQyxJQUFZO0lBQ3pDLE9BQU8sSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUMvQixDQUFDO0FBRkQsd0NBRUMifQ==
@@ -1 +0,0 @@
1
- export {};
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /*
7
- * This program is under the terms of the GNU Affero General Public License version 3
8
- * The full license information can be found in LICENSE in the root directory of this project.
9
- */
10
- const ava_1 = __importDefault(require("ava"));
11
- const url_1 = require("./url");
12
- (0, ava_1.default)('removeEndingSlash should remove ending slash', (t) => {
13
- t.is((0, url_1.removeEndingSlash)('foo/'), 'foo');
14
- });
15
- (0, ava_1.default)('removeEndingSlash should do nothing for empty string', (t) => {
16
- t.is((0, url_1.removeEndingSlash)(''), '');
17
- });
18
- (0, ava_1.default)('removeEndingSlash should return empty string from alone slash', (t) => {
19
- t.is((0, url_1.removeEndingSlash)('/'), '');
20
- });
21
- (0, ava_1.default)('removeEndingSlash should do nothing for string without slash', (t) => {
22
- t.is((0, url_1.removeEndingSlash)('text-without-slash'), 'text-without-slash');
23
- });
24
- (0, ava_1.default)('removeEndingSlash should remove last slash of slashes', (t) => {
25
- t.is((0, url_1.removeEndingSlash)('/////////'), '////////');
26
- });
27
- /*
28
- test('should throw error', (t) => {
29
- [null, undefined].forEach((value) => {
30
- t.throws(removeEndingSlash(value), '');
31
- });
32
- });
33
- */
34
- (0, ava_1.default)('addLeadingSlash should do nothing is leading slash is already present', (t) => {
35
- t.is((0, url_1.addLeadingSlash)('foo'), '/foo');
36
- });
37
- (0, ava_1.default)('addLeadingSlash should add leading slash from empty string', (t) => {
38
- t.is((0, url_1.addLeadingSlash)(''), '/');
39
- });
40
- (0, ava_1.default)('addLeadingSlash should add leading slash', (t) => {
41
- t.is((0, url_1.addLeadingSlash)('text-without-slash'), '/text-without-slash');
42
- });
43
- (0, ava_1.default)('addLeadingSlash should add leading slash of slashes', (t) => {
44
- t.is((0, url_1.addLeadingSlash)('/////////'), '/////////');
45
- });
46
- (0, ava_1.default)('addLeadingSlash should do nothing from alone slash', (t) => {
47
- t.is((0, url_1.addLeadingSlash)('/'), '/');
48
- });
49
- /*
50
- test('should throw error', (t) => {
51
- [null, undefined].forEach((value) => {
52
- t.throws(addLeadingSlash(value), '');
53
- });
54
- });
55
- */
56
- (0, ava_1.default)('extractPureURI should extract URI from URL with query', (t) => {
57
- t.is((0, url_1.extractPureURI)('www.foo.com/api/?=bar'), 'www.foo.com/api/');
58
- });
59
- (0, ava_1.default)('extractPureURI should extract URI from URL with fragment', (t) => {
60
- t.is((0, url_1.extractPureURI)('www.foo.com/api/#userInfos'), 'www.foo.com/api/');
61
- });
62
- (0, ava_1.default)('extractPureURI should do nothing from empty string', (t) => {
63
- t.is((0, url_1.extractPureURI)(''), '');
64
- });
65
- (0, ava_1.default)('extractPureURI should do nothing from standalone slash', (t) => {
66
- t.is((0, url_1.extractPureURI)('/'), '/');
67
- });
68
- (0, ava_1.default)('extractPureURI should do nothing from simple text', (t) => {
69
- t.is((0, url_1.extractPureURI)('text-without-slash'), 'text-without-slash');
70
- });
71
- (0, ava_1.default)('extractPureURI should do nothing from slashes', (t) => {
72
- t.is((0, url_1.extractPureURI)('/////////'), '/////////');
73
- });
74
- /*
75
- test('should throw error', (t) => {
76
- [null, undefined].forEach((value) => {
77
- t.throws(extractPureURI(value), '');
78
- });
79
- });
80
- */
81
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXJsLnNwZWMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvaGVscGVyL3VybC5zcGVjLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUE7OztHQUdHO0FBQ0gsOENBQXVCO0FBRXZCLCtCQUEyRTtBQUUzRSxJQUFBLGFBQUksRUFBQyw4Q0FBOEMsRUFBRSxDQUFDLENBQUMsRUFBRSxFQUFFO0lBQ3pELENBQUMsQ0FBQyxFQUFFLENBQUMsSUFBQSx1QkFBaUIsRUFBQyxNQUFNLENBQUMsRUFBRSxLQUFLLENBQUMsQ0FBQztBQUN6QyxDQUFDLENBQUMsQ0FBQztBQUNILElBQUEsYUFBSSxFQUFDLHNEQUFzRCxFQUFFLENBQUMsQ0FBQyxFQUFFLEVBQUU7SUFDakUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxJQUFBLHVCQUFpQixFQUFDLEVBQUUsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDO0FBQ2xDLENBQUMsQ0FBQyxDQUFDO0FBQ0gsSUFBQSxhQUFJLEVBQUMsK0RBQStELEVBQUUsQ0FBQyxDQUFDLEVBQUUsRUFBRTtJQUMxRSxDQUFDLENBQUMsRUFBRSxDQUFDLElBQUE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0FBQyxDQUFDO0FBQ0gsSUFBQSxhQUFJLEVBQUMsd0RBQXdELEVBQUUsQ0FBQyxDQUFDLEVBQUUsRUFBRTtJQUNuRSxDQUFDLENBQUMsRUFBRSxDQUFDLElBQUEsb0JBQWMsRUFBQyxHQUFHLENBQUMsRUFBRSxHQUFHLENBQUMsQ0FBQztBQUNqQyxDQUFDLENBQUMsQ0FBQztBQUNILElBQUEsYUFBSSxFQUFDLG1EQUFtRCxFQUFFLENBQUMsQ0FBQyxFQUFFLEVBQUU7SUFDOUQsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxJQUFBLG9CQUFjLEVBQUMsb0JBQW9CLENBQUMsRUFBRSxvQkFBb0IsQ0FBQyxDQUFDO0FBQ25FLENBQUMsQ0FBQyxDQUFDO0FBQ0gsSUFBQSxhQUFJLEVBQUMsK0NBQStDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsRUFBRTtJQUMxRCxDQUFDLENBQUMsRUFBRSxDQUFDLElBQUEsb0JBQWMsRUFBQyxXQUFXLENBQUMsRUFBRSxXQUFXLENBQUMsQ0FBQztBQUNqRCxDQUFDLENBQUMsQ0FBQztBQUVIOzs7Ozs7RUFNRSJ9
@@ -1 +0,0 @@
1
- export * from './helper/url';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./helper/url"), exports);
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLCtDQUE2QiJ9
@@ -1,66 +0,0 @@
1
- /**
2
- * Simple helper method that remove an ending slash `/` if present.
3
- *
4
- * ### Example (es module)
5
- * ```js
6
- * import { removeEndingSlash } from '@helpers4/url'
7
- * console.log(removeEndingSlash('https://www.google.com/'))
8
- * // => 'https://www.google.com'
9
- * ```
10
- *
11
- * ### Example (commonjs)
12
- * ```js
13
- * var removeEndingSlash = require('@helpers4/url').removeEndingSlash;
14
- * console.log(removeEndingSlash('https://www.google.com/'))
15
- * // => 'https://www.google.com'
16
- * ```
17
- *
18
- * @param url a valid URL
19
- */
20
- export declare function removeEndingSlash(url: string): string;
21
- /**
22
- * Simple helper method that add a leading slash `/` if not yet present.
23
- *
24
- * ### Example (es module)
25
- * ```js
26
- * import { addLeadingSlash } from '@helpers4/url'
27
- * console.log(addLeadingSlash('/your/path/with/leading/slash'))
28
- * // => 'your/path/with/leading/slash'
29
- * ```
30
- *
31
- * ### Example (commonjs)
32
- * ```js
33
- * var addLeadingSlash = require('@helpers4/url').addLeadingSlash;
34
- * console.log(addLeadingSlash('/your/path/with/leading/slash'))
35
- * // => 'your/path/with/leading/slash'
36
- * ```
37
- *
38
- * @param url a valid URL
39
- */
40
- export declare function addLeadingSlash(url: string): string;
41
- /**
42
- * Extract only the URI from a path with optional query and fragments.
43
- *
44
- * For example, all these parameters will returns `/path`:
45
- * - `/path`
46
- * - `/path?query=thing`
47
- * - `/path#fragment`
48
- * - `/path?query=thing#fragment`
49
- *
50
- * ### Example (es module)
51
- * ```js
52
- * import { extractPureURI } from '@helpers4/url'
53
- * console.log(extractPureURI('https://www.google.com/?q=search'))
54
- * // => 'https://www.google.com/'
55
- * ```
56
- *
57
- * ### Example (commonjs)
58
- * ```js
59
- * var extractPureURI = require('@helpers4/url').extractPureURI;
60
- * console.log(extractPureURI('https://www.google.com/?q=search'))
61
- * // => 'https://www.google.com/'
62
- * ```
63
- *
64
- * @param path a complete path without server part.
65
- */
66
- export declare function extractPureURI(path: string): string;
@@ -1,77 +0,0 @@
1
- /*
2
- * This program is under the terms of the GNU Affero General Public License version 3
3
- * The full license information can be found in LICENSE in the root directory of this project.
4
- */
5
- /**
6
- * Simple helper method that remove an ending slash `/` if present.
7
- *
8
- * ### Example (es module)
9
- * ```js
10
- * import { removeEndingSlash } from '@helpers4/url'
11
- * console.log(removeEndingSlash('https://www.google.com/'))
12
- * // => 'https://www.google.com'
13
- * ```
14
- *
15
- * ### Example (commonjs)
16
- * ```js
17
- * var removeEndingSlash = require('@helpers4/url').removeEndingSlash;
18
- * console.log(removeEndingSlash('https://www.google.com/'))
19
- * // => 'https://www.google.com'
20
- * ```
21
- *
22
- * @param url a valid URL
23
- */
24
- export function removeEndingSlash(url) {
25
- return url[url.length - 1] === '/' ? url.slice(0, -1) : url;
26
- }
27
- /**
28
- * Simple helper method that add a leading slash `/` if not yet present.
29
- *
30
- * ### Example (es module)
31
- * ```js
32
- * import { addLeadingSlash } from '@helpers4/url'
33
- * console.log(addLeadingSlash('/your/path/with/leading/slash'))
34
- * // => 'your/path/with/leading/slash'
35
- * ```
36
- *
37
- * ### Example (commonjs)
38
- * ```js
39
- * var addLeadingSlash = require('@helpers4/url').addLeadingSlash;
40
- * console.log(addLeadingSlash('/your/path/with/leading/slash'))
41
- * // => 'your/path/with/leading/slash'
42
- * ```
43
- *
44
- * @param url a valid URL
45
- */
46
- export function addLeadingSlash(url) {
47
- return url[0] === '/' ? url : '/' + url;
48
- }
49
- /**
50
- * Extract only the URI from a path with optional query and fragments.
51
- *
52
- * For example, all these parameters will returns `/path`:
53
- * - `/path`
54
- * - `/path?query=thing`
55
- * - `/path#fragment`
56
- * - `/path?query=thing#fragment`
57
- *
58
- * ### Example (es module)
59
- * ```js
60
- * import { extractPureURI } from '@helpers4/url'
61
- * console.log(extractPureURI('https://www.google.com/?q=search'))
62
- * // => 'https://www.google.com/'
63
- * ```
64
- *
65
- * ### Example (commonjs)
66
- * ```js
67
- * var extractPureURI = require('@helpers4/url').extractPureURI;
68
- * console.log(extractPureURI('https://www.google.com/?q=search'))
69
- * // => 'https://www.google.com/'
70
- * ```
71
- *
72
- * @param path a complete path without server part.
73
- */
74
- export function extractPureURI(path) {
75
- return path.split(/[?#]/)[0];
76
- }
77
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXJsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2hlbHBlci91cmwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7OztHQUdHO0FBRUg7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQWtCRztBQUNILE1BQU0sVUFBVSxpQkFBaUIsQ0FBQyxHQUFXO0lBQzNDLE9BQU8sR0FBRyxDQUFDLEdBQUcsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsS0FBSyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUM7QUFDOUQsQ0FBQztBQUVEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FrQkc7QUFDSCxNQUFNLFVBQVUsZUFBZSxDQUFDLEdBQVc7SUFDekMsT0FBTyxHQUFHLENBQUMsQ0FBQyxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUM7QUFDMUMsQ0FBQztBQUVEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0F3Qkc7QUFDSCxNQUFNLFVBQVUsY0FBYyxDQUFDLElBQVk7SUFDekMsT0FBTyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQy9CLENBQUMifQ==
@@ -1 +0,0 @@
1
- export {};
@@ -1,76 +0,0 @@
1
- /*
2
- * This program is under the terms of the GNU Affero General Public License version 3
3
- * The full license information can be found in LICENSE in the root directory of this project.
4
- */
5
- import test from 'ava';
6
- import { addLeadingSlash, extractPureURI, removeEndingSlash } from './url';
7
- test('removeEndingSlash should remove ending slash', (t) => {
8
- t.is(removeEndingSlash('foo/'), 'foo');
9
- });
10
- test('removeEndingSlash should do nothing for empty string', (t) => {
11
- t.is(removeEndingSlash(''), '');
12
- });
13
- test('removeEndingSlash should return empty string from alone slash', (t) => {
14
- t.is(removeEndingSlash('/'), '');
15
- });
16
- test('removeEndingSlash should do nothing for string without slash', (t) => {
17
- t.is(removeEndingSlash('text-without-slash'), 'text-without-slash');
18
- });
19
- test('removeEndingSlash should remove last slash of slashes', (t) => {
20
- t.is(removeEndingSlash('/////////'), '////////');
21
- });
22
- /*
23
- test('should throw error', (t) => {
24
- [null, undefined].forEach((value) => {
25
- t.throws(removeEndingSlash(value), '');
26
- });
27
- });
28
- */
29
- test('addLeadingSlash should do nothing is leading slash is already present', (t) => {
30
- t.is(addLeadingSlash('foo'), '/foo');
31
- });
32
- test('addLeadingSlash should add leading slash from empty string', (t) => {
33
- t.is(addLeadingSlash(''), '/');
34
- });
35
- test('addLeadingSlash should add leading slash', (t) => {
36
- t.is(addLeadingSlash('text-without-slash'), '/text-without-slash');
37
- });
38
- test('addLeadingSlash should add leading slash of slashes', (t) => {
39
- t.is(addLeadingSlash('/////////'), '/////////');
40
- });
41
- test('addLeadingSlash should do nothing from alone slash', (t) => {
42
- t.is(addLeadingSlash('/'), '/');
43
- });
44
- /*
45
- test('should throw error', (t) => {
46
- [null, undefined].forEach((value) => {
47
- t.throws(addLeadingSlash(value), '');
48
- });
49
- });
50
- */
51
- test('extractPureURI should extract URI from URL with query', (t) => {
52
- t.is(extractPureURI('www.foo.com/api/?=bar'), 'www.foo.com/api/');
53
- });
54
- test('extractPureURI should extract URI from URL with fragment', (t) => {
55
- t.is(extractPureURI('www.foo.com/api/#userInfos'), 'www.foo.com/api/');
56
- });
57
- test('extractPureURI should do nothing from empty string', (t) => {
58
- t.is(extractPureURI(''), '');
59
- });
60
- test('extractPureURI should do nothing from standalone slash', (t) => {
61
- t.is(extractPureURI('/'), '/');
62
- });
63
- test('extractPureURI should do nothing from simple text', (t) => {
64
- t.is(extractPureURI('text-without-slash'), 'text-without-slash');
65
- });
66
- test('extractPureURI should do nothing from slashes', (t) => {
67
- t.is(extractPureURI('/////////'), '/////////');
68
- });
69
- /*
70
- test('should throw error', (t) => {
71
- [null, undefined].forEach((value) => {
72
- t.throws(extractPureURI(value), '');
73
- });
74
- });
75
- */
76
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXJsLnNwZWMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvaGVscGVyL3VybC5zcGVjLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7R0FHRztBQUNILE9BQU8sSUFBSSxNQUFNLEtBQUssQ0FBQztBQUV2QixPQUFPLEVBQUUsZUFBZSxFQUFFLGNBQWMsRUFBRSxpQkFBaUIsRUFBRSxNQUFNLE9BQU8sQ0FBQztBQUUzRSxJQUFJLENBQUMsOENBQThDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsRUFBRTtJQUN6RCxDQUFDLENBQUMsRUFBRSxDQUFDLGlCQUFpQixDQUFDLE1BQU0sQ0FBQyxFQUFFLEtBQUssQ0FBQyxDQUFDO0FBQ3pDLENBQUMsQ0FBQyxDQUFDO0FBQ0gsSU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