Skip to content

Commit 1fcaa50

Browse files
committed
Remove non tested lines
1 parent 9da03a5 commit 1fcaa50

File tree

5 files changed

+3
-44
lines changed

5 files changed

+3
-44
lines changed

src/rules/author.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const wrap = rule => $ => {
3333

3434
if (!isString(value)) return
3535
if (isUrl(value)) return
36-
if (value.includes('|')) return
3736
return sanetize(value)
3837
}
3938

src/rules/date.js

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
const chrono = require('chrono-node')
44
const isIso = require('isostring')
55

6-
const REGEX_POST_META = /(\d{4}[-/]\d{2}[-/]\d{2})/
7-
const REGEX_BY_LINE = /(\w+ \d{2},? \d{4})/
8-
const REGEX_NUMBER = /^[0-9]+$/
9-
106
/**
117
* Wrap a rule with validation and formatting logic.
128
*
@@ -24,13 +20,6 @@ const wrap = rule => $ => {
2420
// convert isodates to restringify, because sometimes they are truncated
2521
if (isIso(value)) return new Date(value).toISOString()
2622

27-
// parse number strings as milliseconds
28-
if (REGEX_NUMBER.test(value)) {
29-
const int = parseInt(value, 10)
30-
const date = new Date(int)
31-
return date.toISOString()
32-
}
33-
3423
// try to parse with the built-in date parser
3524
const native = new Date(value)
3625
if (!isNaN(native.getTime())) return native.toISOString()
@@ -68,24 +57,5 @@ module.exports = [
6857
wrap($ => $('[class*="dateline"]').text()),
6958
wrap($ => $('[class*="date"]').text()),
7059
wrap($ => $('[id*="date"]').text()),
71-
wrap($ => $('[class*="post-meta"]').text()),
72-
wrap(($, url) => {
73-
const match = REGEX_POST_META.exec(url)
74-
if (!match) return
75-
76-
const string = match[1]
77-
const date = new Date(string)
78-
return date.toISOString()
79-
}),
80-
wrap($ => {
81-
const text = $('[class*="byline"]').text()
82-
if (!text) return
83-
84-
const match = REGEX_BY_LINE.exec(text)
85-
if (!match) return
86-
87-
const string = match[1]
88-
const date = new Date(string)
89-
return date.toISOString()
90-
})
60+
wrap($ => $('[class*="post-meta"]').text())
9161
]

src/rules/description.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,5 @@ module.exports = [
4141
wrap($ => $('meta[name="sailthru.description"]').attr('content')),
4242
wrap($ => $('meta[itemprop="description"]').attr('content')),
4343
wrap($ => $('.post-content p').first().text()),
44-
wrap($ => $('.entry-content p').first().text()),
45-
wrap($ => $('article p').first().text())
44+
wrap($ => $('.entry-content p').first().text())
4645
]

src/rules/image.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,5 @@ module.exports = [
3737
wrap($ => $('meta[name="sailthru.image.full"]').attr('content')),
3838
wrap($ => $('meta[name="sailthru.image.thumb"]').attr('content')),
3939
wrap($ => $('article img[src]').first().attr('src')),
40-
wrap($ => $('#content img[src]').first().attr('src')),
41-
wrap($ => $('[class*="article"] img[src]').first().attr('src')),
42-
wrap($ => $('img[src]').first().attr('src'))
40+
wrap($ => $('#content img[src]').first().attr('src'))
4341
]

src/rules/url.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
const normalizeUrl = require('normalize-url')
44
const isString = require('lodash.isstring')
5-
const urlRegex = require('url-regex')
6-
7-
const isUrl = value => urlRegex().test(value)
85

96
/**
107
* Wrap a rule with validation and formatting logic.
@@ -17,10 +14,6 @@ const wrap = rule => $ => {
1714
let value = rule($)
1815
if (!isString(value)) return
1916

20-
// make sure it's a url
21-
value = value.trim()
22-
if (!isUrl(value)) return
23-
2417
return normalizeUrl(value, {
2518
stripWWW: false
2619
})

0 commit comments

Comments
 (0)