feat: Simplify

This commit is contained in:
Simon 2021-04-08 09:20:51 +02:00
parent d57ad3573d
commit 815b3fc030
4 changed files with 7 additions and 9 deletions

View File

@ -1,6 +1,7 @@
import { fileURLToPath } from 'url';
import fs from 'fs';
import path, { dirname } from 'path';
import nhp from 'node-html-parser';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@ -26,3 +27,7 @@ export const extensionFilter = (filenames, extension) => {
export const getContent = (filename) => {
return fs.readFileSync(filename).toString()
}
export const getTitle = (html) => {
return nhp.parse(html).querySelector('title').toString();
}

View File

@ -1,5 +0,0 @@
import nhp from 'node-html-parser';
export const getTitle = (html) => {
return nhp.parse(html).querySelector('title').toString();
}

View File

@ -1,6 +1,5 @@
import Rule from './Rule.js'
import { extensionFilter, getContent } from '../helpers.js'
import { getTitle } from '../parser.js'
import { extensionFilter, getContent, getTitle } from '../helpers.js'
export default class TitleLength extends Rule {
initialize() {

View File

@ -1,6 +1,5 @@
import Rule from './Rule.js'
import { extensionFilter, getContent } from '../helpers.js'
import { getTitle } from '../parser.js'
import { extensionFilter, getContent, getTitle } from '../helpers.js'
export default class TitleUnique extends Rule {
initialize() {