Skip to content

Commit f85921b

Browse files
authored
Merge pull request #106 from ndaidong/v1.5.2
v1.5.2
2 parents 301e23b + 2d39653 commit f85921b

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.5.1",
2+
"version": "1.5.2",
33
"name": "oembed-parser",
44
"description": "Get oEmbed data from given URL.",
55
"homepage": "https://www.npmjs.com/package/oembed-parser",
@@ -15,7 +15,7 @@
1515
"scripts": {
1616
"lint": "standard .",
1717
"pretest": "npm run lint",
18-
"test": "jest --verbose --coverage=true --unhandled-rejections=strict",
18+
"test": "jest --verbose --coverage=true --unhandled-rejections=strict --detectOpenHandles",
1919
"eval": "node eval",
2020
"sync": "node sync",
2121
"tsc": "tsc --init",
@@ -35,6 +35,6 @@
3535
"license": "MIT",
3636
"types": "./index.d.ts",
3737
"dependencies": {
38-
"phin": "^3.6.0"
38+
"got": "^11.8.2"
3939
}
4040
}

src/utils/fetchEmbed.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
// utils -> fetchEmbed
22

3-
const fetch = require('phin')
3+
const got = require('got')
4+
5+
const { name, version } = require('../../package.json')
6+
7+
const fetchOptions = {
8+
headers: {
9+
'user-agent': `${name}/${version}`,
10+
accept: 'application/json; charset=utf-8'
11+
},
12+
timeout: 30 * 1e3,
13+
redirect: 'follow'
14+
}
415

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

5061
const link = getRegularUrl(query, provider.url)
51-
const res = await fetch({ url: link, parse: 'json' })
52-
const body = res.body
62+
const res = got(link, fetchOptions)
63+
const body = await res.json()
5364
body.provider_name = provider_name // eslint-disable-line camelcase
5465
body.provider_url = provider_url // eslint-disable-line camelcase
5566
return body

0 commit comments

Comments
 (0)