Skip to content

Commit

Permalink
Merge pull request #106 from ndaidong/v1.5.2
Browse files Browse the repository at this point in the history
v1.5.2
  • Loading branch information
ndaidong authored Nov 7, 2021
2 parents 301e23b + 2d39653 commit f85921b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.5.1",
"version": "1.5.2",
"name": "oembed-parser",
"description": "Get oEmbed data from given URL.",
"homepage": "https://www.npmjs.com/package/oembed-parser",
Expand All @@ -15,7 +15,7 @@
"scripts": {
"lint": "standard .",
"pretest": "npm run lint",
"test": "jest --verbose --coverage=true --unhandled-rejections=strict",
"test": "jest --verbose --coverage=true --unhandled-rejections=strict --detectOpenHandles",
"eval": "node eval",
"sync": "node sync",
"tsc": "tsc --init",
Expand All @@ -35,6 +35,6 @@
"license": "MIT",
"types": "./index.d.ts",
"dependencies": {
"phin": "^3.6.0"
"got": "^11.8.2"
}
}
17 changes: 14 additions & 3 deletions src/utils/fetchEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
// utils -> fetchEmbed

const fetch = require('phin')
const got = require('got')

const { name, version } = require('../../package.json')

const fetchOptions = {
headers: {
'user-agent': `${name}/${version}`,
accept: 'application/json; charset=utf-8'
},
timeout: 30 * 1e3,
redirect: 'follow'
}

const isFacebookGraphDependent = (provider) => {
return provider.provider_name === 'Facebook' || provider.provider_name === 'Instagram'
Expand Down Expand Up @@ -48,8 +59,8 @@ const fetchEmbed = async (url, provider, params = {}) => {
const query = queries.join('&')

const link = getRegularUrl(query, provider.url)
const res = await fetch({ url: link, parse: 'json' })
const body = res.body
const res = got(link, fetchOptions)
const body = await res.json()
body.provider_name = provider_name // eslint-disable-line camelcase
body.provider_url = provider_url // eslint-disable-line camelcase
return body
Expand Down

0 comments on commit f85921b

Please sign in to comment.