refactor(utils): remove duplicated function (#9972)

Co-authored-by: sebastien <lorber.sebastien@gmail.com>
This commit is contained in:
ozaki 2024-03-29 14:45:30 +01:00 committed by GitHub
parent efbe474e9c
commit 821247142e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 160 additions and 141 deletions

View file

@ -6,7 +6,6 @@
*/
import resolvePathnameUnsafe from 'resolve-pathname';
import {addPrefix, addSuffix, removeSuffix} from './jsUtils';
/**
* Much like `path.join`, but much better. Takes an array of URL segments, and
@ -232,22 +231,6 @@ export function resolvePathname(to: string, from?: string): string {
return resolvePathnameUnsafe(to, from);
}
/** Appends a leading slash to `str`, if one doesn't exist. */
export function addLeadingSlash(str: string): string {
return addPrefix(str, '/');
}
// TODO deduplicate: also present in @docusaurus/utils-common
/** Appends a trailing slash to `str`, if one doesn't exist. */
export function addTrailingSlash(str: string): string {
return addSuffix(str, '/');
}
/** Removes the trailing slash from `str`. */
export function removeTrailingSlash(str: string): string {
return removeSuffix(str, '/');
}
/** Constructs an SSH URL that can be used to push to GitHub. */
export function buildSshUrl(
githubHost: string,