-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added failsafe mechanism which tries to correct wrong usage of u…
…rl building
- Loading branch information
1 parent
3975b16
commit f728ab6
Showing
3 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Removes trailing slashes from a string. | ||
* | ||
* @param str - The input string. | ||
* @returns The string with trailing slashes removed. | ||
*/ | ||
export const removeTrailingSlashes = (str?: string) => | ||
str ? str.replace(/(?<![:/])[/]+$/g, '') : undefined | ||
|
||
/** | ||
* Adds a leading slash to a string if it doesn't already have one. | ||
* | ||
* @param str - The string to add a leading slash to. | ||
* @returns The string with a leading slash. | ||
*/ | ||
export const addLeadingSlash = (str?: string) => | ||
str ? (str.startsWith('/') ? str : '/' + str) : undefined |