Skip to content

Commit ded8fb6

Browse files
azure-sdkweshaggardCopilot
authored
Sync eng/common directory with azure-sdk-tools for PR 13281 (#25748)
* Fix link checks to npm for packages * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Apply suggestion from @weshaggard --------- Co-authored-by: Wes Haggard <[email protected]> Co-authored-by: Wes Haggard <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 8029c00 commit ded8fb6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

eng/common/scripts/Verify-Links.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ function ProcessLink([System.Uri]$linkUri) {
120120
# See comment in function below for details.
121121
return ProcessCratesIoLink $linkUri $matches['path']
122122
}
123+
elseif ($linkUri -match '^https?://(www\.)?npmjs\.com/package/.+') {
124+
return ProcessNpmLink $linkUri
125+
}
123126
else {
124127
return ProcessStandardLink $linkUri
125128
}
@@ -157,6 +160,14 @@ function ProcessCratesIoLink([System.Uri]$linkUri, $path) {
157160
return $true
158161
}
159162

163+
function ProcessNpmLink([System.Uri]$linkUri) {
164+
# npmjs.com started using Cloudflare which returns 403 and we need to instead check the registry api for existence checks
165+
# https://github.com/orgs/community/discussions/174098#discussioncomment-14461226
166+
$apiUrl = $linkUri.ToString() -replace '^https?://(?:www\.)?npmjs\.com/package/(.*)/v', 'https://registry.npmjs.org/$1'
167+
168+
return ProcessStandardLink ([System.Uri]$apiUrl)
169+
}
170+
160171
function ProcessStandardLink([System.Uri]$linkUri) {
161172
$headRequestSucceeded = $true
162173
try {

0 commit comments

Comments
 (0)