reachable-url 1.6.10 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +18 -8
  2. package/package.json +11 -2
package/index.js CHANGED
@@ -2,7 +2,22 @@
2
2
 
3
3
  const pReflect = require('p-reflect')
4
4
  const { URL } = require('url')
5
- const got = require('got')
5
+
6
+ const got = require('got').extend({
7
+ decompress: false,
8
+ responseType: 'buffer',
9
+ retry: 1,
10
+ headers: {
11
+ Range: 'bytes=0-0'
12
+ },
13
+ hooks: {
14
+ beforeRetry: [
15
+ options => {
16
+ delete options.headers.range
17
+ }
18
+ ]
19
+ }
20
+ })
6
21
 
7
22
  const mergeResponse = (responseOrigin = {}, responseDestination = {}) => ({
8
23
  statusMessage: 'Not Found',
@@ -12,12 +27,8 @@ const mergeResponse = (responseOrigin = {}, responseDestination = {}) => ({
12
27
  ...responseDestination
13
28
  })
14
29
 
15
- const reachableUrl = async (url, opts = {}) => {
16
- const req = got(url, {
17
- ...opts,
18
- retry: 0,
19
- responseType: 'buffer'
20
- })
30
+ const reachableUrl = async (url, opts) => {
31
+ const req = got(url, opts)
21
32
 
22
33
  const redirectStatusCodes = []
23
34
  const redirectUrls = []
@@ -25,7 +36,6 @@ const reachableUrl = async (url, opts = {}) => {
25
36
 
26
37
  req.on('response', res => {
27
38
  response = res
28
- response.once('data', () => req.cancel())
29
39
  })
30
40
 
31
41
  req.on('redirect', res => {
package/package.json CHANGED
@@ -2,13 +2,23 @@
2
2
  "name": "reachable-url",
3
3
  "description": "Given an url resolve it as fast as possible",
4
4
  "homepage": "https://nicedoc.io/Kikobeats/reachable-url",
5
- "version": "1.6.10",
5
+ "version": "1.7.0",
6
6
  "main": "index.js",
7
7
  "author": {
8
8
  "email": "josefrancisco.verdu@gmail.com",
9
9
  "name": "Kiko Beats",
10
10
  "url": "https://kikobeats.com"
11
11
  },
12
+ "contributors": [
13
+ {
14
+ "name": "Shu Ding",
15
+ "email": "g@shud.in"
16
+ },
17
+ {
18
+ "name": "Kenrick",
19
+ "email": "kenrick95@gmail.com"
20
+ }
21
+ ],
12
22
  "repository": {
13
23
  "type": "git",
14
24
  "url": "git+https://github.com/Kikobeats/reachable-url.git"
@@ -57,7 +67,6 @@
57
67
  "contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
58
68
  "lint": "standard",
59
69
  "postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
60
- "precommit": "nano-staged",
61
70
  "prerelease": "npm run update:check && npm run contributors",
62
71
  "pretest": "npm run lint",
63
72
  "preversion": "git-authors-cli && git add package.json",