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

microlinkhq / metascraper / 3873014738

pending completion
3873014738

push

github

Kiko Beats
chore(release): v5.33.4

744 of 768 branches covered (96.88%)

Branch coverage included in aggregate %.

2441 of 2476 relevant lines covered (98.59%)

491.02 hits per line

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

98.18
/packages/metascraper-iframe/src/from-twitter.js
1
'use strict'
2✔
2

2✔
3
const { normalizeUrl, memoizeOne } = require('@metascraper/helpers')
2✔
4
const { map } = require('lodash')
2✔
5

2✔
6
const getPlayerUrl = memoizeOne((url, $) => {
2✔
7
  const playerUrl =
3✔
8
    $('meta[name="twitter:player"]').attr('content') ||
3✔
9
    $('meta[property="twitter:player"]').attr('content')
1✔
10

3✔
11
  return playerUrl === undefined ? undefined : normalizeUrl(url, playerUrl)
3✔
12
}, memoizeOne.EqualityUrlAndHtmlDom)
2✔
13

2✔
14
const playerWidth = $ =>
2✔
15
  $('meta[name="twitter:player:width"]').attr('content') ||
3✔
16
  $('meta[property="twitter:player:width"]').attr('content')
1✔
17

2✔
18
const playerHeight = $ =>
2✔
19
  $('meta[name="twitter:player:height"]').attr('content') ||
3✔
20
  $('meta[property="twitter:player:height"]').attr('content')
1✔
21

2✔
22
const fromTwitter = () => async ({ htmlDom, url, iframe }) => {
2✔
23
  const playerUrl = getPlayerUrl(url, htmlDom)
3✔
24
  if (!playerUrl) return
3!
25

3✔
26
  const props = map(
3✔
27
    { width: playerWidth(htmlDom), height: playerHeight(htmlDom), ...iframe },
3✔
28
    (value, key) => (value === undefined ? value : `${key}="${value}"`)
3✔
29
  )
3✔
30
    .filter(Boolean)
3✔
31
    .join(' ')
3✔
32

3✔
33
  return `<iframe src="${playerUrl}" frameborder="0" scrolling="no" ${props}></iframe>`
3✔
34
}
3✔
35

2✔
36
fromTwitter.test = (url, $) => getPlayerUrl(url, $) !== undefined
2✔
37

2✔
38
module.exports = fromTwitter
2✔
39
module.exports.getPlayerUrl = getPlayerUrl
2✔
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