• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

microlinkhq / metascraper / 7360669003

29 Dec 2023 11:58PM UTC coverage: 94.193%. First build
7360669003

Pull #683

github

web-flow
Merge 57740dd88 into 04d321c4b
Pull Request #683: feat(video): improve iframe detection

1729 of 1947 branches covered (0.0%)

Branch coverage included in aggregate %.

2537 of 2582 relevant lines covered (98.26%)

414.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.46
/packages/metascraper-date/src/index.js
1
'use strict'
105✔
2

105✔
3
const { date, $filter, $jsonld, toRule } = require('@metascraper/helpers')
105✔
4

105✔
5
const toDate = toRule(date)
105✔
6

105✔
7
const dateRules = () => {
105✔
8
  return [
139✔
9
    toDate($ => $('meta[name="date" i]').attr('content')),
139✔
10
    toDate($ => $('[itemprop*="date" i]').attr('content')),
139✔
11
    toDate($ => $('time[itemprop*="date" i]').attr('datetime')),
139✔
12
    toDate($ => $('time[datetime]').attr('datetime')),
139✔
13
    toDate($ => $filter($, $('[class*="byline" i]'))),
139✔
14
    toDate($ => $filter($, $('[id*="date" i]'))),
139✔
15
    toDate($ => $filter($, $('[class*="date" i]'))),
139✔
16
    toDate($ => $filter($, $('[class*="time" i]')))
139✔
17
  ]
139✔
18
}
139✔
19

105✔
20
const datePublishedRules = () => {
105✔
21
  return [
139✔
22
    toDate($jsonld('datePublished')),
139✔
23
    toDate($jsonld('dateCreated')),
139✔
24
    toDate($ => $('meta[property*="published_time" i]').attr('content')),
139✔
25
    toDate($ => $('[itemprop="datepublished" i]').attr('content')),
139✔
26
    toDate($ => $filter($, $('[class*="publish" i]')))
139✔
27
  ]
139✔
28
}
139✔
29

105✔
30
const dateModifiedRules = () => {
105✔
31
  return [
139✔
32
    toDate($jsonld('dateModified')),
139✔
33
    toDate($ => $('meta[property*="modified_time" i]').attr('content')),
139✔
34
    toDate($ => $('[itemprop*="datemodified" i]').attr('content'))
139✔
35
  ]
139✔
36
}
139✔
37

105✔
38
module.exports = (
105✔
39
  { datePublished, dateModified } = {
139✔
40
    datePublished: false,
139✔
41
    dateModified: false
139✔
42
  }
139✔
43
) => {
139✔
44
  const result = {
139✔
45
    date: dateModifiedRules().concat(datePublishedRules(), dateRules())
139✔
46
  }
139✔
47

139✔
48
  if (datePublished) {
139!
49
    result.datePublished = datePublishedRules()
×
50
  }
×
51

139✔
52
  if (dateModified) {
139!
53
    result.dateModified = dateModifiedRules()
×
54
  }
×
55

139✔
56
  return result
139✔
57
}
139✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc