From 454f6eb09e380e7bb49c45ddfa9af5473f3374f0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Sep 2025 20:57:21 +0000 Subject: [PATCH 1/5] Initial plan From 543136ddd47a0d7633ddad240a86b42539252724 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Sep 2025 21:03:19 +0000 Subject: [PATCH 2/5] Move proxy URL to rule option in external-links rule Co-authored-by: fulldecent <382183+fulldecent@users.noreply.github.com> --- .htmlvalidate.mjs | 7 +++++- test/plugin.html-validate.external-links.mjs | 25 +++++++++++++++----- test/plugin.html-validate.mjs | 7 +++++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.htmlvalidate.mjs b/.htmlvalidate.mjs index 56a5106..8d332ba 100644 --- a/.htmlvalidate.mjs +++ b/.htmlvalidate.mjs @@ -5,7 +5,12 @@ export default defineConfig({ extends: ["html-validate:prettier", "/test/plugin.html-validate.mjs:recommended"], rules: { "pacific-medical-training/mailto-awesome": "error", - "pacific-medical-training/external-links": "error", + "pacific-medical-training/external-links": [ + "error", + { + proxyUrl: "https://api.PacificMedicalTraining.com/public/link-check/status", + }, + ], "pacific-medical-training/no-jquery": "error", "pacific-medical-training/canonical-link": "error", "pacific-medical-training/latest-packages": "error", diff --git a/test/plugin.html-validate.external-links.mjs b/test/plugin.html-validate.external-links.mjs index d96e6a7..fcc4417 100644 --- a/test/plugin.html-validate.external-links.mjs +++ b/test/plugin.html-validate.external-links.mjs @@ -12,10 +12,8 @@ const TIMEOUT_SECONDS = 5; const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.9999.999 Safari/537.36"; -// Use your proxy server to check external links -// This URL must accept a query parameter `url` and return the status code and possibly location: header in the response. -// Status code 500 is returned if the server is down or timeout. -const PROXY_URL = "https://api.PacificMedicalTraining.com/public/link-check/status"; +// Default proxy URL if none is provided via options +const DEFAULT_PROXY_URL = "https://api.PacificMedicalTraining.com/public/link-check/status"; // html-validate runs check() synchronously, so we can't use async functions like fetch here. Maybe after their // version 9 release we can use the fetch API and this parallel approach. @@ -61,6 +59,21 @@ function normalizeUrl(url) { } export default class ExternalLinksRule extends Rule { + constructor(options) { + super(options); + this.proxyUrl = options?.proxyUrl || DEFAULT_PROXY_URL; + } + + static schema() { + return { + proxyUrl: { + type: "string", + description: + "URL of proxy server to check external links. Must accept a query parameter 'url' and return the status code and possibly location: header in the response.", + }, + }; + } + documentation() { return { description: "Require all external links to be live.", @@ -142,7 +155,7 @@ export default class ExternalLinksRule extends Rule { // Normalize URL to handle case-insensitive domains const normalizedUrl = normalizeUrl(url); - const urlWithQuery = `${PROXY_URL}?url=${encodeURIComponent(url)}`; + const urlWithQuery = `${this.proxyUrl}?url=${encodeURIComponent(url)}`; // Use shell-quote to safely escape the URL const escapedUrl = shellEscape([urlWithQuery]); @@ -218,7 +231,7 @@ export default class ExternalLinksRule extends Rule { } } - if (PROXY_URL !== null) { + if (this.proxyUrl !== null) { this.checkWithProxy(url, target); } else { this.check(url, target); diff --git a/test/plugin.html-validate.mjs b/test/plugin.html-validate.mjs index 57e4ed9..45bb220 100644 --- a/test/plugin.html-validate.mjs +++ b/test/plugin.html-validate.mjs @@ -23,7 +23,12 @@ export default definePlugin({ recommended: { rules: { "pacific-medical-training/mailto-awesome": "error", - "pacific-medical-training/external-links": "error", + "pacific-medical-training/external-links": [ + "error", + { + proxyUrl: "https://api.PacificMedicalTraining.com/public/link-check/status", + }, + ], "pacific-medical-training/no-jquery": "error", "pacific-medical-training/canonical-link": "error", "pacific-medical-training/latest-packages": "error", From 53059afd75ea7e02837d968b13f9882155dcc3b9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Sep 2025 18:32:18 +0000 Subject: [PATCH 3/5] Remove default proxy URL from external-links plugin and recommended config Co-authored-by: fulldecent <382183+fulldecent@users.noreply.github.com> --- test/plugin.html-validate.external-links.mjs | 6 +++--- test/plugin.html-validate.mjs | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/test/plugin.html-validate.external-links.mjs b/test/plugin.html-validate.external-links.mjs index fcc4417..4c98867 100644 --- a/test/plugin.html-validate.external-links.mjs +++ b/test/plugin.html-validate.external-links.mjs @@ -12,8 +12,7 @@ const TIMEOUT_SECONDS = 5; const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.9999.999 Safari/537.36"; -// Default proxy URL if none is provided via options -const DEFAULT_PROXY_URL = "https://api.PacificMedicalTraining.com/public/link-check/status"; + // html-validate runs check() synchronously, so we can't use async functions like fetch here. Maybe after their // version 9 release we can use the fetch API and this parallel approach. @@ -61,7 +60,7 @@ function normalizeUrl(url) { export default class ExternalLinksRule extends Rule { constructor(options) { super(options); - this.proxyUrl = options?.proxyUrl || DEFAULT_PROXY_URL; + this.proxyUrl = options?.proxyUrl; } static schema() { @@ -70,6 +69,7 @@ export default class ExternalLinksRule extends Rule { type: "string", description: "URL of proxy server to check external links. Must accept a query parameter 'url' and return the status code and possibly location: header in the response.", + required: true, }, }; } diff --git a/test/plugin.html-validate.mjs b/test/plugin.html-validate.mjs index 45bb220..57e4ed9 100644 --- a/test/plugin.html-validate.mjs +++ b/test/plugin.html-validate.mjs @@ -23,12 +23,7 @@ export default definePlugin({ recommended: { rules: { "pacific-medical-training/mailto-awesome": "error", - "pacific-medical-training/external-links": [ - "error", - { - proxyUrl: "https://api.PacificMedicalTraining.com/public/link-check/status", - }, - ], + "pacific-medical-training/external-links": "error", "pacific-medical-training/no-jquery": "error", "pacific-medical-training/canonical-link": "error", "pacific-medical-training/latest-packages": "error", From e0424b53c04deb46d355c697d14480f80a7212f1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Sep 2025 19:03:17 +0000 Subject: [PATCH 4/5] Make proxyUrl option optional instead of required Co-authored-by: fulldecent <382183+fulldecent@users.noreply.github.com> --- test/plugin.html-validate.external-links.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/plugin.html-validate.external-links.mjs b/test/plugin.html-validate.external-links.mjs index 4c98867..b7c5fdc 100644 --- a/test/plugin.html-validate.external-links.mjs +++ b/test/plugin.html-validate.external-links.mjs @@ -69,7 +69,6 @@ export default class ExternalLinksRule extends Rule { type: "string", description: "URL of proxy server to check external links. Must accept a query parameter 'url' and return the status code and possibly location: header in the response.", - required: true, }, }; } @@ -231,7 +230,7 @@ export default class ExternalLinksRule extends Rule { } } - if (this.proxyUrl !== null) { + if (this.proxyUrl) { this.checkWithProxy(url, target); } else { this.check(url, target); From d63a47870111df09cf2b850432f4905bd0445e17 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Sep 2025 20:00:10 +0000 Subject: [PATCH 5/5] Fix linting errors in external-links plugin Co-authored-by: fulldecent <382183+fulldecent@users.noreply.github.com> --- test/plugin.html-validate.external-links.mjs | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/plugin.html-validate.external-links.mjs b/test/plugin.html-validate.external-links.mjs index b7c5fdc..35610d2 100644 --- a/test/plugin.html-validate.external-links.mjs +++ b/test/plugin.html-validate.external-links.mjs @@ -12,8 +12,6 @@ const TIMEOUT_SECONDS = 5; const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.9999.999 Safari/537.36"; - - // html-validate runs check() synchronously, so we can't use async functions like fetch here. Maybe after their // version 9 release we can use the fetch API and this parallel approach. /**