forked from zyborg/dotnet-tests-report
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action_helpers.ps1
41 lines (35 loc) · 1001 Bytes
/
action_helpers.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function splitListInput { $args[0] -split ',' | % { $_.Trim() } }
function writeListInput { $args[0] | % { Write-ActionInfo " - $_" } }
function Resolve-EscapeTokens {
param(
[object]$Message,
[object]$Context,
[switch]$UrlEncode
)
$m = ''
$Message = $Message.ToString()
$p2 = -1
$p1 = $Message.IndexOf('%')
while ($p1 -gt -1) {
$m += $Message.Substring($p2 + 1, $p1 - $p2 - 1)
$p2 = $Message.IndexOf('%', $p1 + 1)
if ($p2 -lt 0) {
$m += $Message.Substring($p1)
break
}
$etName = $Message.Substring($p1 + 1, $p2 - $p1 - 1)
if ($etName -eq '') {
$etValue = '%'
}
else {
$etValue = $Context.$etName
}
$m += $etValue
$p1 = $Message.IndexOf('%', $p2 + 1)
}
$m += $Message.Substring($p2 + 1)
if ($UrlEncode) {
$m = [System.Web.HTTPUtility]::UrlEncode($m).Replace('+', '%20')
}
$m
}