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

@ -12,6 +12,10 @@ export type ApplyTrailingSlashParams = Pick<
'trailingSlash' | 'baseUrl'
>;
export function addTrailingSlash(str: string): string {
return str.endsWith('/') ? str : `${str}/`;
}
// Trailing slash handling depends in some site configuration options
export default function applyTrailingSlash(
path: string,
@ -24,10 +28,6 @@ export default function applyTrailingSlash(
return path;
}
// TODO deduplicate: also present in @docusaurus/utils
function addTrailingSlash(str: string): string {
return str.endsWith('/') ? str : `${str}/`;
}
function removeTrailingSlash(str: string): string {
return str.endsWith('/') ? str.slice(0, -1) : str;
}

View file

@ -11,6 +11,7 @@ export const blogPostContainerID = '__blog-post-container';
export {
default as applyTrailingSlash,
addTrailingSlash,
type ApplyTrailingSlashParams,
} from './applyTrailingSlash';
export {getErrorCausalChain} from './errorUtils';