Skip to content

Commit

Permalink
added some unit tests and removed check for unicode ampersand character
Browse files Browse the repository at this point in the history
  • Loading branch information
ehaines1 committed Nov 12, 2024
1 parent 477f2b7 commit be01712
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions PowerShell/ScubaGear/Modules/Orchestrator.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ function Format-PlainText {
$CleanString = $CleanString -replace '(.*)(<a href=")([\w#./=&?%\-+:;$@,]+)(".*>)(.*)(</a>)(.*)', '$1$5, $3$7'
$CleanString = $CleanString.Replace("<", "&lt;")
$CleanString = $CleanString.Replace(">", "&gt;")
$CleanString = $CleanString.Replace("&", "&amp;")
#$CleanString = $CleanString.Replace("&", "&amp;")
$CleanString
}
}
Expand Down Expand Up @@ -1064,7 +1064,6 @@ function Merge-JsonOutput {
# Convert the output a json string
$MetaData = ConvertTo-Json $MetaData -Depth 3
$Results = ConvertTo-Json $Results -Depth 5
# Loop through each property
$Summary = ConvertTo-Json $Summary -Depth 3
$ReportJson = @"
{
Expand All @@ -1080,7 +1079,7 @@ function Merge-JsonOutput {
$ReportJson = $ReportJson.replace("\u003c", "<")
$ReportJson = $ReportJson.replace("\u003e", ">")
$ReportJson = $ReportJson.replace("\u0027", "'")
$ReportJson = $ReportJson.replace("\u0026", "&")
$ReportJson = $ReportJson.replace("$amp;", "&")

# Save the file
$JsonFileName = Join-Path -Path $OutFolderPath "$($OutJsonFileName).json" -ErrorAction 'Stop'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ InModuleScope Orchestrator {
}
It 'Reformats links with special symbols' {
$Output = Format-PlainText 'See <a href="https://example.com#anchor?p1=v1&p2=v2" target="_blank">this example</a> for more details.'
$Output | Should -Be "See this example, https://example.com#anchor?p1=v1&amp;p2=v2 for more details."
$Output | Should -Be "See this example, https://example.com#anchor?p1=v1&p2=v2 for more details."
}
It 'Reformats links without target' {
$Output = Format-PlainText 'See <a href="example.com">this example</a> for more details.'
$Output | Should -Be "See this example, example.com for more details."
}
It 'Reformats links when there is no trailing content' {
$Output = Format-PlainText 'See <a href="https://example.com#anchor?p1=v1&p2=v2" target="_blank">this example</a>.'
$Output | Should -Be "See this example, https://example.com#anchor?p1=v1&amp;p2=v2."
$Output | Should -Be "See this example, https://example.com#anchor?p1=v1&p2=v2."
}
}
}
Expand Down

0 comments on commit be01712

Please sign in to comment.