diff --git a/services/w3c/w3c-validation-helper.js b/services/w3c/w3c-validation-helper.js
index 5880ac3faf18c..d747ab7e87cd1 100644
--- a/services/w3c/w3c-validation-helper.js
+++ b/services/w3c/w3c-validation-helper.js
@@ -88,7 +88,9 @@ The rules are as follows:
non-document-error: These messages are counted as errors
-This badge relies on the https://validator.nu/ service to perform the validation.
+This badge relies on the Nu validator service to perform the validation. By default it
+uses https://validator.nu/; pass \`validator=validator.w3.org\` to use the W3C-hosted
+deployment at https://validator.w3.org/nu/ instead.
Please refer to https://about.validator.nu/ for the full documentation and Terms of service.
`
diff --git a/services/w3c/w3c-validation.service.js b/services/w3c/w3c-validation.service.js
index 0993e668cb6e6..5ddb06a298317 100644
--- a/services/w3c/w3c-validation.service.js
+++ b/services/w3c/w3c-validation.service.js
@@ -27,6 +27,9 @@ const schema = Joi.object({
const queryParamSchema = Joi.object({
targetUrl: url,
preset: Joi.string().regex(presetRegex).allow(''),
+ validator: Joi.equal('validator.nu', 'validator.w3.org').default(
+ 'validator.nu',
+ ),
}).required()
const parserDescription = `The parser that is used for validation. This is a passthru value to the service
@@ -85,6 +88,17 @@ export default class W3cValidation extends BaseJsonService {
],
},
}),
+ queryParam({
+ name: 'validator',
+ example: 'validator.w3.org',
+ description: `The Nu validator deployment to use. This is a passthru choice of host, both run the same engine and API:
+- \`validator.nu\` (default): the original hsivonen-hosted service
+- \`validator.w3.org\`: the W3C-hosted deployment, at https://validator.w3.org/nu/`,
+ schema: {
+ type: 'string',
+ enum: ['validator.nu', 'validator.w3.org'],
+ },
+ }),
],
},
},
@@ -101,9 +115,13 @@ export default class W3cValidation extends BaseJsonService {
}
}
- async fetch(targetUrl, preset, parser) {
+ async fetch(targetUrl, preset, parser, validator) {
+ const validatorUrl =
+ validator === 'validator.w3.org'
+ ? 'https://validator.w3.org/nu/'
+ : 'https://validator.nu/'
return this._requestJson({
- url: 'https://validator.nu/',
+ url: validatorUrl,
schema,
options: {
searchParams: {
@@ -155,8 +173,13 @@ export default class W3cValidation extends BaseJsonService {
}, {})
}
- async handle({ parser }, { targetUrl, preset }) {
- const { url, messages } = await this.fetch(targetUrl, preset, parser)
+ async handle({ parser }, { targetUrl, preset, validator }) {
+ const { url, messages } = await this.fetch(
+ targetUrl,
+ preset,
+ parser,
+ validator,
+ )
return this.constructor.render({
messageTypes: this.transform(url, messages),
})
diff --git a/services/w3c/w3c-validation.tester.js b/services/w3c/w3c-validation.tester.js
index f7cc4880c62c8..36e98656d0202 100644
--- a/services/w3c/w3c-validation.tester.js
+++ b/services/w3c/w3c-validation.tester.js
@@ -98,3 +98,27 @@ t.create('W3C Validation page has multiple of validation errors with red badge')
message: isW3CMessage,
color: isW3CColors,
})
+
+t.create(
+ 'W3C Validation via validator.w3.org: page conforms to standards with brightgreen badge',
+)
+ .get(
+ '/default.json?targetUrl=https://hsivonen.com/test/moz/messages-types/no-message.html&validator=validator.w3.org',
+ )
+ .expectBadge({
+ label: 'w3c',
+ message: isW3CMessage,
+ color: isW3CColors,
+ })
+
+t.create(
+ 'W3C Validation via validator.w3.org: page has 1 validation error with red badge',
+)
+ .get(
+ '/html.json?targetUrl=http://hsivonen.com/test/moz/messages-types/warning.html&validator=validator.w3.org',
+ )
+ .expectBadge({
+ label: 'w3c',
+ message: isW3CMessage,
+ color: isW3CColors,
+ })