fix: Correct URL encoding for folder paths with spaces

This commit is contained in:
Bobby Abellana (aider) 2025-02-21 09:32:38 -08:00
parent c30d7ccdc5
commit 7fb87bdccf

View File

@ -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"