refactor(utils): remove duplicated function

This commit is contained in:
ozakione 2024-03-13 19:50:49 +01:00
parent 8d115a9e0d
commit 50347c77e7
14 changed files with 18 additions and 25 deletions

View file

@ -19,6 +19,7 @@
"license": "MIT",
"dependencies": {
"@docusaurus/logger": "3.0.0",
"@docusaurus/utils-common": "3.0.0",
"@svgr/webpack": "^6.5.1",
"escape-string-regexp": "^4.0.0",
"file-loader": "^6.2.0",

View file

@ -5,12 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
import {addTrailingSlash} from '@docusaurus/utils-common';
import {
normalizeUrl,
getEditUrl,
fileToPath,
isValidPathname,
addTrailingSlash,
addLeadingSlash,
removeTrailingSlash,
resolvePathname,

View file

@ -51,7 +51,6 @@ export {
parseURLPath,
serializeURLPath,
addLeadingSlash,
addTrailingSlash,
removeTrailingSlash,
hasSSHProtocol,
buildHttpsUrl,

View file

@ -6,7 +6,7 @@
*/
import resolvePathnameUnsafe from 'resolve-pathname';
import {addPrefix, addSuffix, removeSuffix} from './jsUtils';
import {addPrefix, removeSuffix} from './jsUtils';
/**
* Much like `path.join`, but much better. Takes an array of URL segments, and
@ -237,12 +237,6 @@ 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, '/');