Skip to content

Commit 594980c

Browse files
authored
Merge pull request #10 from wild-devops/develop
Fix filters bug with ':' in input
2 parents 658bf43 + a3fefd6 commit 594980c

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![GitHub workflows (all tests)](https://github.com/wild-devops/pwshake/workflows/all%20tests/badge.svg)](../../actions/workflows/tests.yml)
2-
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/wild-devops/pwshake)](../../releases/tag/v1.5.2)
2+
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/wild-devops/pwshake)](../../releases/tag/v1.5.3)
33
[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/pwshake)](https://www.powershellgallery.com/packages/pwshake)
44
[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/pwshake)](https://www.powershellgallery.com/packages/pwshake)
55

@@ -123,7 +123,7 @@ invoke_tasks:
123123
attributes:
124124
pwshake_module_path: /path/to/pwshake/module/source
125125
pwshake_path: /absolute/path/to/your/working/directory
126-
pwshake_version: 1.5.2
126+
pwshake_version: 1.5.3
127127
work_dir: /absolute/path/to/process/working/directory
128128
pwshake_log_path: /absolute/path/to/your/working/directory/my_pwshake.log
129129
some_attribute: this is an attribute value

pwshake/pwshake.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'pwshake.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.5.2'
15+
ModuleVersion = '1.5.3'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -52,7 +52,7 @@
5252

5353
# Modules that must be imported into the global environment prior to importing this module
5454
RequiredModules = @(
55-
@{ModuleName = "powershell-yaml"; RequiredVersion = "0.4.0"; Guid = "6a75a662-7f53-425a-9777-ee61284407da" }
55+
@{ModuleName = "powershell-yaml"; RequiredVersion = "0.4.2"; Guid = "6a75a662-7f53-425a-9777-ee61284407da" }
5656
)
5757

5858
# Assemblies that must be loaded prior to importing this module

pwshake/scripts/Interpolate-Attributes.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ function Interpolate-Attributes {
1313
do {
1414
foreach ($substitute in (Get-Matches $json $regex 'subst')) {
1515
"Interpolate-Attributes:$($counter):`$substitute:$substitute" | f-log-dbg
16-
if ($substitute -match '^\$\((?<eval>.*)\)$') {
16+
if ($substitute -match '(?ms)^\$\((?<eval>.*)\)$') {
1717
"Interpolate-Attributes:$($counter):`$eval:{$($matches.eval)}" | f-log-dbg
1818
$value = "`"$($matches.eval)`"" | ConvertFrom-Json | Invoke-Expression
19-
} elseif ($substitute -match '^(?<filter>\$\S+):(?<input>.*)') {
19+
} elseif ($substitute -match '(?ms)^(?<filter>\$\S+?):(?<input>.*)$') {
2020
"Interpolate-Attributes:$($counter):`$filter:{$($matches.filter)}:`$input:{$($matches.input)}" | f-log-dbg
2121
$value = "`"$($matches.input)`"" | ConvertFrom-Json | & f-$($matches.filter)
2222
"Interpolate-Attributes:$($counter):`$value:{$value}" | f-log-dbg

tests/Interpolate-Attributes.Context.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Context "Interpolate-Attributes" {
6262
@{When='{{a}}';And='dev';Then='.dev'}
6363
@{When='{{b}}';And='dev';Then='.dev'}
6464
) {param($When, $And, $Then)
65-
$subst = '{{$("' + $When + '" | ? {$_} | % {".$_"})}}'
65+
$subst = '{{$("' + $When + '" | ? {$_} | % {' + [Environment]::NewLine + '".$_"})}}'
6666
(Interpolate-Attributes @{
6767
attributes = @{
6868
a = $And
@@ -133,4 +133,16 @@ Context "Interpolate-Attributes" {
133133
$actual.attributes.b | Should -Be $chars
134134
$actual.attributes.c | Should -Be $chars
135135
}
136+
137+
It "Should substitute filters with multiple ':' separators and multiline input" {
138+
$expected = "https://some.url/?other`nvalue1:value2"
139+
140+
Interpolate-Attributes @{
141+
attributes = @{a="{{b}}";b='{{$secured:{{c}}}}';c=$expected};
142+
} | New-Variable -Name actual
143+
144+
$actual.attributes.a | Should -Be $expected
145+
$actual.attributes.b | Should -Be $expected
146+
$actual.attributes.c | Should -Be $expected
147+
}
136148
}

0 commit comments

Comments
 (0)