Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using w3cjs with validator in local docker container #40

Open
scottnath opened this issue Oct 21, 2019 · 0 comments
Open

using w3cjs with validator in local docker container #40

scottnath opened this issue Oct 21, 2019 · 0 comments

Comments

@scottnath
Copy link

Recently the nu checker has been timing out on us and we needed a local solution to reduce false-negatives. I have set up the nu validator using their Nu Html Checker validator/validator docker image. Using a local nu version also cuts about 100ms off of each request.

I would like to use this image/container with w3cjs, but the w3cCheckUrl is not configurable as far as I can tell. Is it possible to add a configuration for w3cCheckUrl to the options object? Something like this:

...

var defaultW3cCheckUrl = 'http://validator.w3.org/nu/';
var defaultOutput = 'json';
...

function setW3cCheckUrl(newW3cCheckUrl) {
	defaultW3cCheckUrl = newW3cCheckUrl;
}

function validate(options) {
	var output = options.output || defaultOutput;
	var callback = options.callback || defaultCallback;
	options.w3cCheckUrl = options.w3cCheckUrl || defaultW3cCheckUrl;

...

var getRequest = function(isLocal, options) {
	var req = isLocal ? proxyRequest.post(options.w3cCheckUrl) : proxyRequest.get(options.w3cCheckUrl);

I could use a proxy, but due to the varying local and CI testing locations it would be prohibitive to set up multiple proxies to do this.

The usage of above would be something like...

const validateHtml = html =>
  new Promise((resolve, reject) => {
    w3cjs.validate({
      w3cCheckUrl: 'http://127.0.0.1:8888',
      input: html,
      output: 'json',
...

I can submit a PR for this if it's something that would be accepted.

thanks for a great module!
Scott

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant