mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-19 17:49:19 +02:00
More fixes
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
This commit is contained in:
parent
6d3d416f58
commit
c7c833fe77
16 changed files with 59 additions and 32 deletions
|
@ -21,6 +21,9 @@ export default function applyTrailingSlash(
|
|||
function removeTrailingSlash(str: string): string {
|
||||
return str.endsWith('/') ? str.slice(0, -1) : str;
|
||||
}
|
||||
function handleTrailingSlash(str: string, trailing: boolean): string {
|
||||
return trailing ? addTrailingSlash(str) : removeTrailingSlash(str);
|
||||
}
|
||||
|
||||
// undefined = legacy retrocompatible behavior
|
||||
if (typeof trailingSlash === 'undefined') {
|
||||
|
@ -32,10 +35,6 @@ export default function applyTrailingSlash(
|
|||
|
||||
// Never transform '/' to ''
|
||||
const newPathname =
|
||||
pathname === '/'
|
||||
? '/'
|
||||
: trailingSlash
|
||||
? addTrailingSlash(pathname)
|
||||
: removeTrailingSlash(pathname);
|
||||
pathname === '/' ? '/' : handleTrailingSlash(pathname, trailingSlash);
|
||||
return path.replace(pathname, newPathname);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue