mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Add function to combine web Urls properly
This commit is contained in:
parent
312fd4a03f
commit
6425066bac
1 changed files with 24 additions and 0 deletions
24
lib/core/tools/Join-WebPath.psm1
Normal file
24
lib/core/tools/Join-WebPath.psm1
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
function Join-WebPath()
|
||||||
|
{
|
||||||
|
param(
|
||||||
|
[string]$Path,
|
||||||
|
[string]$ChildPath
|
||||||
|
);
|
||||||
|
|
||||||
|
if ([string]::IsNullOrEmpty($Path) -Or [string]::IsNullOrEmpty($ChildPath)) {
|
||||||
|
return $Path;
|
||||||
|
}
|
||||||
|
|
||||||
|
[int]$Length = $Path.Length;
|
||||||
|
[int]$Slash = $Path.LastIndexOf('/') + 1;
|
||||||
|
|
||||||
|
if ($Length -eq $Slash) {
|
||||||
|
$Path = $Path.Substring(0, $Path.Length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ChildPath[0] -eq '/') {
|
||||||
|
return ([string]::Format('{0}{1}', $Path, $ChildPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ([string]::Format('{0}/{1}', $Path, $ChildPath));
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue