mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-07 20:07:59 +02:00
refactor(utils): remove duplicated function
This commit is contained in:
parent
8d115a9e0d
commit
50347c77e7
14 changed files with 18 additions and 25 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ export const blogPostContainerID = '__blog-post-container';
|
|||
|
||||
export {
|
||||
default as applyTrailingSlash,
|
||||
addTrailingSlash,
|
||||
type ApplyTrailingSlashParams,
|
||||
} from './applyTrailingSlash';
|
||||
export {getErrorCausalChain} from './errorUtils';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue