Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 1062 (#16389)
Browse files Browse the repository at this point in the history
Sync eng/common directory with azure-sdk-tools for PR Azure/azure-sdk-tools#1062
 See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/master/eng/common/README.md#workflow)
  • Loading branch information
azure-sdk committed Oct 16, 2020
1 parent 48eb1b8 commit ce5ec0a
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 ce5ec0a

Please sign in to comment.