fix(v2): sitemap plugin should handle siteConfig.trailingSlash automatically (#4950)

* create new @docusaurus/utils-common and move applyTrailingSlash there

* sitemap plugin should handle siteConfig.trailingSlash automatically

* typo
This commit is contained in:
Sébastien Lorber 2021-06-14 20:04:39 +02:00 committed by GitHub
parent 4e5f0febb9
commit aeb8e9da51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 127 additions and 35 deletions

View file

@ -313,13 +313,15 @@ export function resolvePathname(to: string, from?: string): string {
export function addLeadingSlash(str: string): string {
return str.startsWith('/') ? str : `/${str}`;
}
export function addTrailingSlash(str: string): string {
return str.endsWith('/') ? str : `${str}/`;
}
export function addTrailingPathSeparator(str: string): string {
return str.endsWith(path.sep) ? str : `${str}${path.sep}`;
}
// TODO deduplicate: also present in @docusaurus/utils-common
export function addTrailingSlash(str: string): string {
return str.endsWith('/') ? str : `${str}/`;
}
export function removeTrailingSlash(str: string): string {
return removeSuffix(str, '/');
}