fix(theme-common): isSamePath should be case-insensitive (#6758)

This commit is contained in:
Sébastien Lorber 2022-02-25 14:58:54 +01:00 committed by GitHub
parent 39b66d82ef
commit 44a65f3337
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View file

@ -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);
};