Skip to content

Commit

Permalink
Merge pull request #726 from microlinkhq/logo-faicon
Browse files Browse the repository at this point in the history
fix(metascraper-logo-favicon): use normalized URL
  • Loading branch information
Kikobeats authored Oct 5, 2024
2 parents 7a504f7 + 6ee2c66 commit f769532
Show file tree
Hide file tree
Showing 33 changed files with 12,835 additions and 6,436 deletions.
2 changes: 1 addition & 1 deletion packages/metascraper-logo-favicon/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const getDomNodeSizes = (domNodes, attr, url) =>
{
...domNode.attribs,
url: normalizedUrl,
size: getSize(url, domNode.attribs.sizes)
size: getSize(normalizedUrl, domNode.attribs.sizes)
}
]
}, [])
Expand Down
11 changes: 11 additions & 0 deletions packages/metascraper-logo-favicon/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ test('get the biggest icon possible', async t => {
t.is(metadata.logo, 'https://cdn.microlink.io/logo/favicon-196x196.png')
})

test('get the biggest respecting the format', async t => {
const url = 'https://github.com'
const metascraper = createMetascraper()
const html = createHtml([
'<link rel="icon" type="image/png" href="/fluidicon.png" sizes="96x96">',
'<link rel="icon" type="image/x-icon" href="/favicon.ico" sizes="128x128">'
])
const metadata = await metascraper({ url, html })
t.is(metadata.logo, 'https://github.com/fluidicon.png')
})

test('detect `rel="fluid-icon"`', async t => {
const url = 'https://github.com'
const metascraper = createMetascraper()
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-soundcloud/test/snapshots/index.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Generated by [AVA](https://avajs.dev).
description: 'Thanks for 5.000 likes on https://www.facebook.com/BeautyBrainMusic :D <3 <3 <3',
image: 'https://i1.sndcdn.com/artworks-000069142357-nwttc6-t500x500.jpg',
lang: 'en',
logo: 'https://a-v2.sndcdn.com/assets/images/sc-icons/favicon-2cadd14bdb.ico',
logo: 'https://a-v2.sndcdn.com/assets/images/sc-icons/ios-a62dfc8fe7.png',
publisher: 'SoundCloud',
title: 'Swag Bandicoot [FREE DOWNLOAD]',
url: 'https://soundcloud.com/beautybrainsp/beauty-brain-swag-bandicoot',
Expand Down
Binary file modified packages/metascraper-soundcloud/test/snapshots/index.js.snap
Binary file not shown.
3,019 changes: 2,491 additions & 528 deletions packages/metascraper/test/integration/arstechnica/input.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Generated by [AVA](https://avajs.dev).
{
audio: null,
author: 'Chris Stokel-Walker',
date: '2017-06-11T14:00:33.000Z',
author: 'Ars Staff',
date: '2017-06-11T14:11:02.000Z',
description: 'For original YouTubers, their online haven became a media behemoth—but they keep vlogging.',
image: 'https://cdn.arstechnica.net/wp-content/uploads/2017/06/Screen-Shot-2017-06-08-at-1.32.44-PM-760x380.png',
image: 'https://cdn.arstechnica.net/wp-content/uploads/2017/06/Screen-Shot-2017-06-08-at-1.32.44-PM.png',
lang: 'en',
logo: 'https://cdn.arstechnica.net/wp-content/themes/ars/assets/img/material-ars-db41652381.png',
logo: 'https://cdn.arstechnica.net/wp-content/uploads/2016/10/cropped-ars-logo-512_480.png',
publisher: 'Ars Technica',
title: 'More than a decade later, how do original YouTube stars feel about the site?',
url: 'https://arstechnica.com/features/2017/06/youtube-changed-my-life-a-pair-of-original-videostars-ponder-a-life-lived-online/',
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Generated by [AVA](https://avajs.dev).
description: 'If IT is going to better align themselves with business operations, they must be able to objectively quantify the value of the cloud.',
image: 'http://images.techhive.com/images/article/2015/06/msftone_cloudperspective4-100588855-primary.idge.png',
lang: 'en',
logo: 'https://idge.staticworld.net/cio/CIO_logo_144x144.png',
logo: 'https://idge.staticworld.net/cio/CIO_logo_300x300.png',
publisher: 'CIO',
title: '20 Ways to Measure the Success of Your Growing Cloud Investment',
url: 'http://www.cio.com/article/2929788/cloud-computing/20-ways-to-measure-the-success-of-your-growing-cloud-investment.html',
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Generated by [AVA](https://avajs.dev).
description: 'My healthcare data is what I want protected the most (intimate details about my family’s health, where we live, and financial information). Anything and everything a hacker could want! It is safe? As a data security professional and citizen, I know the answer is not good.',
image: 'http://images.techhive.com/images/article/2016/04/blog-31_apr15_image-1-100656409-primary.idge.jpg',
lang: 'en',
logo: 'https://idge.staticworld.net/ctw/computerworld-logo144x144.png',
logo: 'https://idge.staticworld.net/ctw/computerworld-logo300x300.png',
publisher: 'Computerworld',
title: 'Healthcare Data Protection and Privacy Prognosis—Still Critical but New Treatment is Available',
url: 'http://www.computerworld.com/article/3057179/data-analytics/healthcare-data-protection-and-privacy-prognosis-still-critical-but-new-treatment-is-available.html',
Expand Down
Binary file not shown.
31 changes: 0 additions & 31 deletions packages/metascraper/test/integration/health/index.js

This file was deleted.

Loading

0 comments on commit f769532

Please sign in to comment.