Skip to content

Commit

Permalink
Failed the anchor links with Uppercase. (#14535)
Browse files Browse the repository at this point in the history
Co-authored-by: Sima Zhu <sizhu@microsoft.com>
  • Loading branch information
azure-sdk and sima-zhu authored Oct 16, 2020
1 parent ae380a5 commit 9c365cb
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions eng/common/scripts/Verify-Links.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ param (
$ProgressPreference = "SilentlyContinue"; # Disable invoke-webrequest progress dialog
# Regex of the locale keywords.
$locale = "/en-us/"
$emptyLinkMessage = "There is at least one empty link in the page. Please replace with absolute link. Check here for more infomation: https://aka.ms/azsdk/guideline/links"
$emptyLinkMessage = "There is at least one empty link in the page. Please replace with absolute link. Check here for more information: https://aka.ms/azsdk/guideline/links"
function NormalizeUrl([string]$url){
if (Test-Path $url) {
$url = "file://" + (Resolve-Path $url).ToString();
Expand Down Expand Up @@ -137,7 +137,7 @@ function ParseLinks([string]$baseUri, [string]$htmlContent)
function CheckLink ([System.Uri]$linkUri)
{
if(!$linkUri.ToString().Trim()) {
LogWarning "Found Empty link. Please use absolute link instead. Check here for more infomation: https://aka.ms/azsdk/guideline/links"
LogWarning "Found Empty link. Please use absolute link instead. Check here for more information: https://aka.ms/azsdk/guideline/links"
return $false
}
if ($checkedLinks.ContainsKey($linkUri)) {
Expand All @@ -156,7 +156,7 @@ function CheckLink ([System.Uri]$linkUri)
$linkValid = $false
}
}
else {
elseif ($linkUri.IsAbsoluteUri) {
try {
$headRequestSucceeded = $true
try {
Expand Down Expand Up @@ -200,9 +200,15 @@ function CheckLink ([System.Uri]$linkUri)
}

if ($checkLinkGuidance) {
$link = $linkUri.ToString()
# Check if the url is relative links, suppress the archor link validation.
if (!$linkUri.IsAbsoluteUri -and !$linkUri.ToString().StartsWith("#")) {
LogWarning "DO NOT use relative link $linkUri. Please use absolute link instead. Check here for more infomation: https://aka.ms/azsdk/guideline/links"
if (!$linkUri.IsAbsoluteUri -and !$link.StartsWith("#")) {
LogWarning "DO NOT use relative link $linkUri. Please use absolute link instead. Check here for more information: https://aka.ms/azsdk/guideline/links"
$linkValid = $false
}
# Check if the url is anchor link has any uppercase.
if ($link -cmatch '#[^?]*[A-Z]') {
LogWarning "Please lower case your anchor tags (i.e. anything after '#' in your link '$linkUri'. Check here for more information: https://aka.ms/azsdk/guideline/links"
$linkValid = $false
}
# Check if link uri includes locale info.
Expand Down

0 comments on commit 9c365cb

Please sign in to comment.