|
| 1 | +<# |
| 2 | + .SYNOPSIS |
| 3 | + Check broken links. |
| 4 | +
|
| 5 | + .DESCRIPTION |
| 6 | + The Verify-Links.ps1 script will check whether the files contain any broken links. |
| 7 | +
|
| 8 | + .PARAMETER urls |
| 9 | + Specify url list to verify links. Can either be a http address or a local file request. Local file paths support md and html files. |
| 10 | +
|
| 11 | + .PARAMETER ignoreLinksFile |
| 12 | + Specifies the file that contains a set of links to ignore when verifying. |
| 13 | +
|
| 14 | + .PARAMETER devOpsLogging |
| 15 | + Switch that will enable devops specific logging for warnings |
| 16 | +
|
| 17 | + .PARAMETER recursive |
| 18 | + Check the links recurisvely based on recursivePattern. |
| 19 | + |
| 20 | + .PARAMETER baseUrl |
| 21 | + Recursively check links for all links verified that begin with this baseUrl, defaults to the folder the url is contained in. |
| 22 | + |
| 23 | + .PARAMETER rootUrl |
| 24 | + Path to the root of the site for resolving rooted relative links, defaults to host root for http and file directory for local files. |
| 25 | + |
| 26 | + .PARAMETER errorStatusCodes |
| 27 | + List of http status codes that count as broken links. Defaults to 400, 401, 404, SocketError.HostNotFound = 11001, SocketError.NoData = 11004. |
| 28 | + |
| 29 | + .PARAMETER branchReplaceRegex |
| 30 | + Regex to check if the link needs to be replaced. E.g. ^(https://github.com/.*/(?:blob|tree)/)master(/.*)$ |
| 31 | + |
| 32 | + .PARAMETER branchReplacementName |
| 33 | + The substitute branch name or SHA commit. |
| 34 | + |
| 35 | + .PARAMETER checkLinkGuidance |
| 36 | + Flag to allow checking against azure sdk link guidance. Check link guidance here: https://aka.ms/azsdk/guideline/links. |
| 37 | + |
| 38 | + .PARAMETER userAgent |
| 39 | + UserAgent to be configured for web requests. Defaults to current Chrome version. |
| 40 | +
|
| 41 | + .INPUTS |
| 42 | + None. No required inputs. |
| 43 | +
|
| 44 | + .OUTPUTS |
| 45 | + None. Verify-Links.ps1 does not generate any output. |
| 46 | +
|
| 47 | + .EXAMPLE |
| 48 | + PS> .\Verify-Links.ps1 |
| 49 | +
|
| 50 | + .EXAMPLE |
| 51 | + PS> .\Verify-Links.ps1 -urls C:\README.md |
| 52 | +
|
| 53 | + .EXAMPLE |
| 54 | + PS> .\Verify-Links -urls C:\README.md -checkLinkGuidance $true |
| 55 | +#> |
1 | 56 | param ( |
2 | | - # url list to verify links. Can either be a http address or a local file request. Local file paths support md and html files. |
3 | 57 | [string[]] $urls, |
4 | | - # file that contains a set of links to ignore when verifying |
5 | 58 | [string] $ignoreLinksFile = "$PSScriptRoot/ignore-links.txt", |
6 | | - # switch that will enable devops specific logging for warnings |
7 | 59 | [switch] $devOpsLogging = $false, |
8 | | - # check the links recurisvely based on recursivePattern |
9 | 60 | [switch] $recursive = $true, |
10 | | - # recusiving check links for all links verified that begin with this baseUrl, defaults to the folder the url is contained in |
11 | 61 | [string] $baseUrl = "", |
12 | | - # path to the root of the site for resolving rooted relative links, defaults to host root for http and file directory for local files |
13 | 62 | [string] $rootUrl = "", |
14 | | - # list of http status codes count as broken links. Defaults to 400, 401, 404, SocketError.HostNotFound = 11001, SocketError.NoData = 11004 |
15 | 63 | [array] $errorStatusCodes = @(400, 401, 404, 11001, 11004), |
16 | | - # regex to check if the link needs to be replaced |
17 | | - [string] $branchReplaceRegex = "^(https://github.com/.*/(?:blob|tree)/)master(/.*)$", |
18 | | - # the substitute branch name or SHA commit |
| 64 | + [string] $branchReplaceRegex = "", |
19 | 65 | [string] $branchReplacementName = "", |
20 | | - # flag to allow checking against azure sdk link guidance. Check link guidance here: https://aka.ms/azsdk/guideline/links |
21 | 66 | [bool] $checkLinkGuidance = $false, |
22 | | - # UserAgent to be configured for web request. Default to current Chrome version. |
23 | 67 | [string] $userAgent |
24 | 68 | ) |
25 | 69 |
|
|
0 commit comments