4545 . PARAMETER outputCacheFile
4646 Path to a file that the script will output all the validated links after running all checks.
4747
48+ . PARAMETER localGithubClonedRoot
49+ Path to the root of a local github clone. This is used to resolve links to local files in the repo instead of making web requests.
50+
51+ . PARAMETER localBuildRepoName
52+ The name of the repo that is being built. This is used to resolve links to local files in the repo instead of making web requests.
53+
54+ . PARAMETER localBuildRepoPath
55+ The path to the local build repo. This is used to resolve links to local files in the repo instead of making web requests.
56+
4857 . PARAMETER requestTimeoutSec
4958 The number of seconds before we timeout when sending an individual web request. Default is 15 seconds.
5059
@@ -73,7 +82,9 @@ param (
7382 [string ] $inputCacheFile ,
7483 [string ] $outputCacheFile ,
7584 [string ] $localGithubClonedRoot = " " ,
76- [string ] $requestTimeoutSec = 15
85+ [string ] $localBuildRepoName = " " ,
86+ [string ] $localBuildRepoPath = " " ,
87+ [string ] $requestTimeoutSec = 15
7788)
7889
7990Set-StrictMode - Version 3.0
@@ -82,8 +93,17 @@ $ProgressPreference = "SilentlyContinue"; # Disable invoke-webrequest progress d
8293
8394function ProcessLink ([System.Uri ]$linkUri ) {
8495 # To help improve performance and rate limiting issues with github links we try to resolve them based on a local clone if one exists.
85- if ($localGithubClonedRoot -and $linkUri -match ' ^https://github.com/Azure/(?<repo>[^/]+)/(?:blob|tree)/(main|.*_[^/]+|.*/v[^/]+)/(?<path>.*)$' ) {
86- $localPath = Join-Path $localGithubClonedRoot $matches [' repo' ] $matches [' path' ]
96+ if (($localGithubClonedRoot -or $localBuildRepoName ) -and $linkUri -match ' ^https://github.com/(?<org>Azure)/(?<repo>[^/]+)/(?:blob|tree)/(main|.*_[^/]+|.*/v[^/]+)/(?<path>.*)$' ) {
97+
98+ if ($localBuildRepoName -eq ($matches [' org' ] + " /" + $matches [' repo' ])) {
99+ # If the link is to the current repo, use the local build path
100+ $localPath = Join-Path $localBuildRepoPath $matches [' path' ]
101+ }
102+ else {
103+ # Otherwise use the local github clone path
104+ $localPath = Join-Path $localGithubClonedRoot $matches [' repo' ] $matches [' path' ]
105+ }
106+
87107 if (Test-Path $localPath ) {
88108 return $true
89109 }
@@ -165,7 +185,7 @@ $emptyLinkMessage = "There is at least one empty link in the page. Please replac
165185if (! $userAgent ) {
166186 $userAgent = " Chrome/87.0.4280.88"
167187}
168- function NormalizeUrl ([string ]$url ){
188+ function NormalizeUrl ([string ]$url ) {
169189 if (Test-Path $url ) {
170190 $url = " file://" + (Resolve-Path $url ).ToString();
171191 }
0 commit comments