From 3a05f6f1860712d4c6d163167e59c4de6ba7eda9 Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Tue, 9 Dec 2025 14:01:53 -0800 Subject: [PATCH 1/3] Fix link checks to npm for packages --- eng/common/scripts/Verify-Links.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/eng/common/scripts/Verify-Links.ps1 b/eng/common/scripts/Verify-Links.ps1 index fe04a9b1db2a..3207ae9ab995 100644 --- a/eng/common/scripts/Verify-Links.ps1 +++ b/eng/common/scripts/Verify-Links.ps1 @@ -120,6 +120,9 @@ function ProcessLink([System.Uri]$linkUri) { # See comment in function below for details. return ProcessCratesIoLink $linkUri $matches['path'] } + elseif ($linkUri -match '^https?://(www\.)?npmjs\.com/package/.+') { + return ProcessNpmLink $linkUri + } else { return ProcessStandardLink $linkUri } @@ -157,6 +160,14 @@ function ProcessCratesIoLink([System.Uri]$linkUri, $path) { return $true } +function ProcessNpmLink([System.Uri]$linkUri) { + # npmjs.com started using Cloudflare which returns 403 and we need to instead check the registry api for existence checks + # https://github.com/orgs/community/discussions/174098#discussioncomment-14461226 + $apiUrl = $linkUri.ToString().Replace("https://www.npmjs.com/package/", "https://registry.npmjs.org/") + + return ProcessStandardLink ([System.Uri]$apiUrl) +} + function ProcessStandardLink([System.Uri]$linkUri) { $headRequestSucceeded = $true try { From d5951368fffc4c8acbe622a45fea197be99974ac Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Tue, 9 Dec 2025 14:21:42 -0800 Subject: [PATCH 2/3] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- eng/common/scripts/Verify-Links.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/Verify-Links.ps1 b/eng/common/scripts/Verify-Links.ps1 index 3207ae9ab995..ee7200937753 100644 --- a/eng/common/scripts/Verify-Links.ps1 +++ b/eng/common/scripts/Verify-Links.ps1 @@ -163,7 +163,7 @@ function ProcessCratesIoLink([System.Uri]$linkUri, $path) { function ProcessNpmLink([System.Uri]$linkUri) { # npmjs.com started using Cloudflare which returns 403 and we need to instead check the registry api for existence checks # https://github.com/orgs/community/discussions/174098#discussioncomment-14461226 - $apiUrl = $linkUri.ToString().Replace("https://www.npmjs.com/package/", "https://registry.npmjs.org/") + $apiUrl = $linkUri.ToString() -replace '^https?://(www\.)?npmjs\.com/package/', 'https://registry.npmjs.org/' return ProcessStandardLink ([System.Uri]$apiUrl) } From 1a6f811b4aea80802fa6f842e94c9231531e14ab Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Wed, 10 Dec 2025 11:36:50 -0800 Subject: [PATCH 3/3] Apply suggestion from @weshaggard --- eng/common/scripts/Verify-Links.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/Verify-Links.ps1 b/eng/common/scripts/Verify-Links.ps1 index ee7200937753..d0ac61d79542 100644 --- a/eng/common/scripts/Verify-Links.ps1 +++ b/eng/common/scripts/Verify-Links.ps1 @@ -163,7 +163,7 @@ function ProcessCratesIoLink([System.Uri]$linkUri, $path) { function ProcessNpmLink([System.Uri]$linkUri) { # npmjs.com started using Cloudflare which returns 403 and we need to instead check the registry api for existence checks # https://github.com/orgs/community/discussions/174098#discussioncomment-14461226 - $apiUrl = $linkUri.ToString() -replace '^https?://(www\.)?npmjs\.com/package/', 'https://registry.npmjs.org/' + $apiUrl = $linkUri.ToString() -replace '^https?://(?:www\.)?npmjs\.com/package/(.*)/v', 'https://registry.npmjs.org/$1' return ProcessStandardLink ([System.Uri]$apiUrl) }