From 1d3abd3d1dfbbe2f1718e3398af25537234906ed Mon Sep 17 00:00:00 2001 From: dpilafian Date: Fri, 10 Nov 2023 00:58:25 -0800 Subject: [PATCH] Release v1.6.1 #12 --- dist/w3c-html-validator.d.ts | 2 +- dist/w3c-html-validator.js | 14 ++++++++------ package.json | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/dist/w3c-html-validator.d.ts b/dist/w3c-html-validator.d.ts index 33c1e9c..9674bba 100644 --- a/dist/w3c-html-validator.d.ts +++ b/dist/w3c-html-validator.d.ts @@ -1,4 +1,4 @@ -//! w3c-html-validator v1.6.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License +//! w3c-html-validator v1.6.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License export type ValidatorSettings = { html: string; diff --git a/dist/w3c-html-validator.js b/dist/w3c-html-validator.js index 655b468..d344e0e 100644 --- a/dist/w3c-html-validator.js +++ b/dist/w3c-html-validator.js @@ -1,11 +1,12 @@ -//! w3c-html-validator v1.6.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License +//! w3c-html-validator v1.6.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License import chalk from 'chalk'; import fs from 'fs'; import log from 'fancy-log'; import request from 'superagent'; +import slash from 'slash'; const w3cHtmlValidator = { - version: '1.6.0', + version: '1.6.1', validate(options) { const defaults = { checkUrl: 'https://validator.w3.org/nu/', @@ -20,9 +21,10 @@ const w3cHtmlValidator = { throw Error('[w3c-html-validator] Invalid ignoreLevel option: ' + settings.ignoreLevel); if (settings.output !== 'json' && settings.output !== 'html') throw Error('[w3c-html-validator] Option "output" must be "json" or "html".'); - const mode = settings.html ? 'html' : settings.filename ? 'filename' : 'website'; + const filename = settings.filename ? slash(settings.filename) : null; + const mode = settings.html ? 'html' : filename ? 'filename' : 'website'; const readFile = (filename) => fs.readFileSync(filename, 'utf-8').replace(/\r/g, ''); - const inputHtml = settings.html ?? (settings.filename ? readFile(settings.filename) : null); + const inputHtml = settings.html ?? (filename ? readFile(filename) : null); const makePostRequest = () => request.post(settings.checkUrl) .set('Content-Type', 'text/html; encoding=utf-8') .send(inputHtml); @@ -35,7 +37,7 @@ const w3cHtmlValidator = { const success = '

'; const titleLookup = { html: 'HTML String (characters: ' + inputHtml?.length + ')', - filename: settings.filename, + filename: filename, website: settings.website, }; const filterMessages = (response) => { @@ -52,7 +54,7 @@ const w3cHtmlValidator = { mode: mode, title: titleLookup[mode], html: inputHtml, - filename: settings.filename || null, + filename: filename, website: settings.website || null, output: settings.output, status: response.statusCode || -1, diff --git a/package.json b/package.json index e82582f..25901ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "w3c-html-validator", - "version": "1.6.0", + "version": "1.6.1", "description": "Check the markup validity of HTML files using the W3C validator", "license": "MIT", "type": "module",