From 7fb87bdccfa10bf51cec9a6b92628754446d140b Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Fri, 21 Feb 2025 09:32:38 -0800 Subject: [PATCH] fix: Correct URL encoding for folder paths with spaces --- SharePointFunctions.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SharePointFunctions.ps1 b/SharePointFunctions.ps1 index de97f89..5352239 100644 --- a/SharePointFunctions.ps1 +++ b/SharePointFunctions.ps1 @@ -71,7 +71,7 @@ function List-XlsFiles { $script:txtStatus.Text += "Searching in folder: $folderPath`n" # Get the folder ID first # Construct the correct URI for the folder - # Remove the /sites/tax/Shared Documents part from the folder path + # Remove the /sites/tax/Shared Documents/ part from the folder path $relativePath = $folderPath.Replace("/sites/tax/Shared Documents/", "").TrimStart("/") # URL encode the relative path @@ -198,8 +198,8 @@ function Get-FolderBrowser { # Remove the /sites/tax/Shared Documents/ part from the folder path $relativePath = $ParentFolderUrl.Replace("/sites/tax/Shared Documents/", "").TrimStart("/") - # URL encode the relative path - $encodedPath = [System.Web.HttpUtility]::UrlEncode($relativePath) + # URL encode the relative path, but replace + with %20 for spaces + $encodedPath = [System.Web.HttpUtility]::UrlEncode($relativePath).Replace("+", "%20") $folderUri = "https://graph.microsoft.com/v1.0/drives/$($drive.Id)/root:/$encodedPath" $script:txtStatus.Text += "Folder URI: $folderUri`n"