Skip to content

Commit

Permalink
feat: remove non necessary he dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed May 31, 2020
1 parent 0a3182e commit d2a33ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"cheerio": "~1.0.0-rc.3",
"debug-logfmt": "~1.0.4",
"got": "~11.1.4",
"he": "~1.2.0",
"html-encode": "~2.1.1",
"lodash": "~4.17.15",
"mime-types": "~2.1.27",
Expand Down
17 changes: 7 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ const PCancelable = require('p-cancelable')
const htmlEncode = require('html-encode')
const timeSpan = require('time-span')
const got = require('got')
const he = require('he')

const autoDomains = require('./auto-domains')
const addHtml = require('./html')

const REQ_TIMEOUT = 8000

const getHtml = html => he.decode(html)

const fetch = (url, { reflect = false, toEncode, ...opts }) =>
new PCancelable(async (resolve, reject, onCancel) => {
const req = got(url, {
Expand All @@ -34,7 +31,7 @@ const fetch = (url, { reflect = false, toEncode, ...opts }) =>
const res = await req
return resolve({
headers: res.headers,
html: getHtml(await toEncode(res.body, res.headers['content-type'])),
html: await toEncode(res.body, res.headers['content-type']),
mode: 'fetch',
url: res.url,
statusCode: res.statusCode
Expand Down Expand Up @@ -64,7 +61,7 @@ const prerender = async (

return {
headers: response.headers(),
html: getHtml(await page.content()),
html: await page.content(),
mode: 'prerender',
url: response.url(),
statusCode: response.status()
Expand All @@ -90,11 +87,11 @@ const prerender = async (

return isFetchResRejected
? {
headers: fetchDataProps.headers || {},
html: '',
url,
mode: 'prerender'
}
headers: fetchDataProps.headers || {},
html: '',
url,
mode: 'prerender'
}
: fetchDataProps
}

Expand Down

0 comments on commit d2a33ae

Please sign in to comment.