mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-08 13:52:36 +02:00
fix(theme-common): isSamePath should be case-insensitive (#6758)
This commit is contained in:
parent
39b66d82ef
commit
44a65f3337
3 changed files with 18 additions and 2 deletions
|
@ -5,12 +5,15 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// Compare the 2 paths, ignoring trailing /
|
||||
// Compare the 2 paths, case insensitive and ignoring trailing slash
|
||||
export const isSamePath = (
|
||||
path1: string | undefined,
|
||||
path2: string | undefined,
|
||||
): boolean => {
|
||||
const normalize = (pathname: string | undefined) =>
|
||||
!pathname || pathname?.endsWith('/') ? pathname : `${pathname}/`;
|
||||
(!pathname || pathname?.endsWith('/')
|
||||
? pathname
|
||||
: `${pathname}/`
|
||||
)?.toLowerCase();
|
||||
return normalize(path1) === normalize(path2);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue