ignore case in protected route matching to fit OneDrive preference

Close #734
This commit is contained in:
myl7 2022-08-04 05:14:57 +00:00
parent 9af1ef4f47
commit 677287d3e2

View file

@ -83,11 +83,12 @@ export async function getAccessToken(): Promise<string> {
*/
export function getAuthTokenPath(path: string) {
// Ensure trailing slashes to compare paths component by component. Same for protectedRoutes.
path += '/'
// Since OneDrive ignores case, lower case before comparing. Same for protectedRoutes.
path = path.toLowerCase() + '/'
const protectedRoutes = siteConfig.protectedRoutes
let authTokenPath = ''
for (let r of protectedRoutes) {
r = r.replace(/\/$/, '') + '/'
r = r.toLowerCase().replace(/\/$/, '') + '/'
if (path.startsWith(r)) {
authTokenPath = `${r}/.password`
break