From 071b10387c593e71c03a4f581c60ec0684a984e2 Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Sun, 14 Jan 2024 11:46:35 +0800 Subject: [PATCH] add more compability to onedrive --- src/remoteForOnedrive.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/remoteForOnedrive.ts b/src/remoteForOnedrive.ts index 1cb1685..f2f14a8 100644 --- a/src/remoteForOnedrive.ts +++ b/src/remoteForOnedrive.ts @@ -273,14 +273,20 @@ const fromDriveItemToRemoteItem = ( // e.g.: /Livefolders/应用/remotely-save/${remoteBaseDir} const SECOND_COMMON_PREFIX_REGEX = /^\/Livefolders\/[^\/]+\/remotely-save\//g; + // another report, why??? + // /drive/root:/something/app/remotely-save/${remoteBaseDir} + const THIRD_COMMON_PREFIX_REGEX = + /^\/drive\/root:\/[^\/]+\/app\/remotely-save\//g; + // another possibile prefix - const THIRD_COMMON_PREFIX_RAW = `/drive/items/`; + const FOURTH_COMMON_PREFIX_RAW = `/drive/items/`; const fullPathOriginal = `${x.parentReference.path}/${x.name}`; const matchFirstPrefixRes = fullPathOriginal.match(FIRST_COMMON_PREFIX_REGEX); const matchSecondPrefixRes = fullPathOriginal.match( SECOND_COMMON_PREFIX_REGEX ); + const matchThirdPrefixRes = fullPathOriginal.match(THIRD_COMMON_PREFIX_REGEX); if ( matchFirstPrefixRes !== null && fullPathOriginal.startsWith(`${matchFirstPrefixRes[0]}${remoteBaseDir}`) @@ -293,7 +299,13 @@ const fromDriveItemToRemoteItem = ( ) { const foundPrefix = `${matchSecondPrefixRes[0]}${remoteBaseDir}`; key = fullPathOriginal.substring(foundPrefix.length + 1); - } else if (x.parentReference.path.startsWith(THIRD_COMMON_PREFIX_RAW)) { + } else if ( + matchThirdPrefixRes !== null && + fullPathOriginal.startsWith(`${matchThirdPrefixRes[0]}${remoteBaseDir}`) + ) { + const foundPrefix = `${matchThirdPrefixRes[0]}${remoteBaseDir}`; + key = fullPathOriginal.substring(foundPrefix.length + 1); + } else if (x.parentReference.path.startsWith(FOURTH_COMMON_PREFIX_RAW)) { // it's something like // /drive/items/!:/${remoteBaseDir}/ // with uri encoded!