Skip to content

Commit 2949e79

Browse files
azure-sdkhallipr
andauthored
HtmlDecode hrefs (#45327)
Co-authored-by: Patrick Hallisey <[email protected]>
1 parent 467b8be commit 2949e79

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

eng/common/scripts/Verify-Links.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,14 @@ function ParseLinks([string]$baseUri, [string]$htmlContent)
283283
$hrefRegex = "<a[^>]+href\s*=\s*[""']?(?<href>[^""']*)[""']?"
284284
$regexOptions = [System.Text.RegularExpressions.RegexOptions]"Singleline, IgnoreCase";
285285

286-
$hrefs = [RegEx]::Matches($htmlContent, $hrefRegex, $regexOptions);
286+
$matches = [RegEx]::Matches($htmlContent, $hrefRegex, $regexOptions);
287287

288-
#$hrefs | Foreach-Object { Write-Host $_ }
288+
Write-Verbose "Found $($matches.Count) raw href's in page $baseUri";
289289

290-
Write-Verbose "Found $($hrefs.Count) raw href's in page $baseUri";
291-
[string[]] $links = $hrefs | ForEach-Object { ResolveUri $baseUri $_.Groups["href"].Value }
290+
# Html encoded urls in anchor hrefs need to be decoded
291+
$urls = $matches | ForEach-Object { [System.Web.HttpUtility]::HtmlDecode($_.Groups["href"].Value) }
292292

293-
#$links | Foreach-Object { Write-Host $_ }
293+
[string[]] $links = $urls | ForEach-Object { ResolveUri $baseUri $_ }
294294

295295
if ($null -eq $links) {
296296
$links = @()

0 commit comments

Comments
 (0)