Skip to content

Commit

Permalink
fix: compose absolute url properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Nov 7, 2019
1 parent 918f1c0 commit 17b55ca
Show file tree
Hide file tree
Showing 4 changed files with 2,469 additions and 746 deletions.
6 changes: 2 additions & 4 deletions packages/metascraper-logo-favicon/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { flow, first, toNumber, split, chain, concat } = require('lodash')
const { logo, url: isUrl } = require('@metascraper/helpers')
const { absoluteUrl, logo, url: isUrl } = require('@metascraper/helpers')
const { URL } = require('url')
const got = require('got')

Expand Down Expand Up @@ -58,9 +58,7 @@ module.exports = () => ({
return size
}),
async ({ url }) => {
const { origin } = new URL(url)
const logoUrl = new URL('favicon.ico', origin)

const logoUrl = absoluteUrl(new URL(url).origin, 'favicon.ico')
try {
await got.head(logoUrl, { retry: 0, timeout: 10000 })
return logo(logoUrl)
Expand Down
17 changes: 15 additions & 2 deletions packages/metascraper/__snapshots__/index.js.snap-shot
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ exports['forbes 1'] = {

exports['fortune 1'] = {
"author": "Kia Kokalitcheva",
"date": "2015-10-05T00:00:00.000Z",
"date": "2015-10-05T20:52:17.000Z",
"description": "HackerRank, a four-year-old startup, is changing the way companies find and evaluate programmers.",
"image": "https://fortunedotcom.files.wordpress.com/2015/09/gettyimages-1852881881.jpg",
"video": null,
"lang": "en",
"logo": "http://fortune.com/img/favicons/favicon-192.png",
"logo": "http://fortune.com/img/logo.png",
"publisher": "Fortune",
"title": "Why your next job search may involve solving online puzzles",
"url": "http://fortune.com/2015/10/05/hackerrank-recruiting-tool/"
Expand Down Expand Up @@ -1007,3 +1007,16 @@ exports['pikabu 1'] = {
"url": "https://pikabu.ru/story/7_interesnyikh_nablyudeniy_o_pervoy_matritse_6758662"
}

exports['bukvy 1'] = {
"author": "Буквы",
"date": "2019-01-06T07:43:59.000Z",
"description": "Президент Петр Порошенко заявил, что государство будет уважать религиозный выбор и вероисповедание каждого гражданина страны. Об этом он заявил в обращении после торжественной церемонии вручения в Стамбуле Томоса об автокефалии Православной церкви Украины. “Я как Президент гарантирую от имени госуда…",
"image": "https://bykvu.com/ru/kd_image_generate/141935.jpg",
"video": null,
"lang": null,
"logo": "https://bykvu.com/wp-content/themes/bykvu/img/apple-icon-180x180.png",
"publisher": "Буквы",
"title": "Украина будет уважать религиозный выбор каждого гражданина, – Порошенко",
"url": "https://bykvu.com/ru/bukvy/107312-ukraina-budet-uvazhat-religioznyj-vybor-kazhdogo-grazhdanina-poroshenko/"
}

Loading

0 comments on commit 17b55ca

Please sign in to comment.