Skip to content

Instantly share code, notes, and snippets.

@hishaamn
Created July 11, 2018 11:44
Show Gist options
  • Save hishaamn/0b8b8703b5cc53f0100af7b1b3e1558c to your computer and use it in GitHub Desktop.
Save hishaamn/0b8b8703b5cc53f0100af7b1b3e1558c to your computer and use it in GitHub Desktop.
function CleanQueryPath {
param([Parameter(Mandatory=$true)] $Path)
$pathComponents = $Path.Split('/')
$cleansedPath = [System.Linq.Enumerable]::Select($pathComponents, [Func[string,string]]{
param($x)
if(($x -like "* *") -or ($x -like "*-*")) {
return "#$($x)#"
}
else {
return "$x"
}
})
return [string]::Join("/", $cleansedPath)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment