OctopusDeploy / Library

| Public | A repository of step templates and other community-contributed extensions to Octopus Deploy
Other
171 stars 504 forks source link

Improved blank line filtering #1449

Closed REOScotte closed 12 months ago

REOScotte commented 1 year ago

Background

After switching to using [StringSplitOptions]::RemoveEmptyEntries, I realized it wasn't trimming lines that were blank AFTER Trim() executed. So I switched back to using .Where({$_})

Using RemoveEmptyEntries, if someone entered the below list, Row 1 would be included, row 2 would be excluded because its a blank line, but row 3 would also be included since it contains a space. Row 4 as normal.

Row1

Row2

However, with .Where({$_}), only Row 1 and 2 would be included. 

Results

Before

After

Pre-requisites

twerthi commented 1 year ago

Have you considered using [string]::IsNullOrWhitespace? This should capture null, empty strings, and spaces.

REOScotte commented 1 year ago

Not sure where it would makes sense. Do you mean inside the .Where clause? Need the Trim() to get rid of errant spaces around a name regardless.