Nice little directory browser :D
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

redirect map: make code more obvious

+15 -20
+15 -20
Routes.ps1
··· 181 181 $Path = $WebEvent.Query.Path 182 182 $JoinedPath = Join-Path $Root $Path 183 183 184 - $Moved = $false 185 - (Get-PodeConfig).Utatane.RedirectMap.GetEnumerator() | % { 186 - if ($Path -eq $_.Key -or ($Path + '/') -eq $_.Key) { 187 - $Moved = @{ 188 - Url = ("/api/files?path=" + (_encode $_.Value)) 189 - } 184 + foreach ($Redirect in (Get-PodeConfig).Utatane.RedirectMap.GetEnumerator()) { 185 + if (-not ($Path -eq $Redirect.Key -or ($Path + '/') -eq $Redirect.Key)) { 186 + continue 190 187 } 191 - } 192 - if ($Moved) { 188 + 189 + $Url = ("/api/files?path=" + (_encode $Redirect.Value)) 190 + 193 191 # api doesn't get a message since they probably aren't keeping the 194 192 # cookie needed for session tracking 195 - 196 - Move-PodeResponseUrl @Moved 197 - return; 193 + Move-PodeResponseUrl -Url $Url 194 + return 198 195 } 199 196 200 197 if (-not (_check_path $Root $JoinedPath)) { ··· 221 218 $Path = $WebEvent.Path ?? '/' 222 219 $JoinedPath = Get-Item -Lit (Join-Path $Root $Path) 223 220 224 - $Moved = $false 225 - (Get-PodeConfig).Utatane.RedirectMap.GetEnumerator() | % { 226 - if ($Path -eq $_.Key) { 227 - $Moved = @{ Url = $_.Value } 221 + foreach ($Redirect in (Get-PodeConfig).Utatane.RedirectMap.GetEnumerator()) { 222 + if ($Path -ne $Redirect.Key) { 223 + continue; 228 224 } 229 - } 230 - if ($Moved) { 231 - Add-PodeFlashMessage -Name redirect-notice -Message @{ 225 + 226 + Add-PodeFlashMessage -name redirect-notice -Message @{ 232 227 From = $Path 233 - To = $Moved.Url 228 + To = $Redirect.Value 234 229 } 235 230 236 - Move-PodeResponseUrl @Moved 231 + Move-PodeResponseUrl -Url $Redirect.Value 237 232 return; 238 233 } 239 234