Skip to content

Commit

Permalink
Normalize line endings on Windows
Browse files Browse the repository at this point in the history
CRLF  -->  LF
  • Loading branch information
dpilafian committed Sep 17, 2022
1 parent d240774 commit 4d5342a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions spec/mocha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import assert from 'assert';

// Setup
import { w3cHtmlValidator } from '../dist/w3c-html-validator.js';
const validHtml = readFileSync('spec/html/valid.html', 'utf8');
const invalidHtml = readFileSync('spec/html/invalid.html', 'utf8');
const validHtml = readFileSync('spec/html/valid.html', 'utf8').replace(/\r/g, '');
const invalidHtml = readFileSync('spec/html/invalid.html', 'utf8').replace(/\r/g, '');

////////////////////////////////////////////////////////////////////////////////////////////////////
describe('The "dist" folder', () => {
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('Valid HTML string', () => {
const expected = {
validates: true,
mode: 'html',
title: 'HTML String (characters: ' + validHtml.length + ')',
title: 'HTML String (characters: 153)',
html: validHtml,
filename: null,
website: null,
Expand All @@ -111,7 +111,7 @@ describe('Valid HTML string', () => {
const expected = {
validates: true,
mode: 'html',
title: 'HTML String (characters: ' + validHtml.length + ')',
title: 'HTML String (characters: 153)',
html: validHtml,
filename: null,
website: null,
Expand Down Expand Up @@ -139,7 +139,7 @@ describe('Invalid HTML string', () => {
const expected = {
validates: false,
mode: 'html',
title: 'HTML String (characters: ' + invalidHtml.length + ')',
title: 'HTML String (characters: 275)',
html: invalidHtml,
filename: null,
website: null,
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('Invalid HTML string', () => {
const expected = {
validates: false,
mode: 'html',
title: 'HTML String (characters: ' + invalidHtml.length + ')',
title: 'HTML String (characters: 275)',
html: invalidHtml,
filename: null,
website: null,
Expand Down Expand Up @@ -331,7 +331,7 @@ describe('Network request failure', () => {
const expected = {
validates: false,
mode: 'html',
title: 'HTML String (characters: ' + validHtml.length + ')',
title: 'HTML String (characters: 153)',
html: validHtml,
filename: null,
website: null,
Expand Down
4 changes: 2 additions & 2 deletions w3c-html-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ const w3cHtmlValidator = {
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 readFile = () => settings.filename ? readFileSync(settings.filename, 'utf8') : null;
const inputHtml = settings.html || readFile();
const readFile = (filename: string) => readFileSync(filename, 'utf8').replace(/\r/g, '');
const inputHtml = settings.html ?? (settings.filename ? readFile(settings.filename) : null);
const makePostRequest = () => request.post(settings.checkUrl)
.set('Content-Type', 'text/html; encoding=utf-8')
.send(<string>inputHtml);
Expand Down

0 comments on commit 4d5342a

Please sign in to comment.