New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Replace url.parse
with new URL()
#701
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3b452b8
chore: replace `url.parse` with `new URL()`
xxczaki dd148fc
Merge branch '3.x' into whatwg-url
xxczaki 4298eab
lint
xxczaki f414fb0
handle relative URLs
xxczaki eb9bed4
Change error message
xxczaki 4a795e7
detect whether the url is absolute or not
xxczaki 7c92e6e
update tests
xxczaki 0a891fb
drop relative url support
xxczaki 1e747be
lint
xxczaki dec4065
fix tests
xxczaki 308a6dc
typo
xxczaki 44cb625
Add information about dropped arbitrary URL support in v3.x upgrade g…
xxczaki a9e7bd8
set xo linting rule (node/no-deprecated-api) to on
xxczaki 34b5595
remove the `utf8` dependency
xxczaki 150a618
Merge branch '3.x' into whatwg-url
xxczaki 35c5503
fix
xxczaki deeb85b
refactor: split tests into several files, create the `utils` directory
xxczaki 886b3d5
Update package.json scripts & remove unnecessary xo linting rules
xxczaki 147da1c
refactor: turn on some xo linting rules to improve code quality
xxczaki 42631e2
fix tests
xxczaki ac60e7a
Remove invalid urls
xxczaki 54a04b7
Merge branch '3.x' into whatwg-url
xxczaki 3002b7f
Merge branch '3.x' into whatwg-url
xxczaki 0f07427
fix merge conflict
xxczaki b102ffe
Merge branch 'whatwg-url' of https://github.com/node-fetch/node-fetch…
xxczaki e1940b0
update the upgrade guide
xxczaki 05bb4c8
test if URLs are encoded as UTF-8
xxczaki File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,161 +1,150 @@ | ||
{ | ||
"name": "node-fetch", | ||
"version": "2.6.0", | ||
"description": "A light-weight module that brings window.fetch to node.js", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
"src/**/*", | ||
"dist/**/*", | ||
"types/**/*.d.ts" | ||
], | ||
"engines": { | ||
"node": ">=10.0.0" | ||
}, | ||
"scripts": { | ||
"build": "pika-pack --out dist/", | ||
"prepare": "npm run build", | ||
"test": "cross-env BABEL_ENV=test mocha --require @babel/register --throw-deprecation test/test.js", | ||
"report": "cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js", | ||
"coverage": "cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json", | ||
"lint": "xo" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/node-fetch/node-fetch.git" | ||
}, | ||
"keywords": [ | ||
"fetch", | ||
"http", | ||
"promise" | ||
], | ||
"author": "David Frank", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/node-fetch/node-fetch/issues" | ||
}, | ||
"homepage": "https://github.com/node-fetch/node-fetch", | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/node-fetch" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.8.7", | ||
"@babel/preset-env": "^7.8.7", | ||
"@babel/register": "^7.8.6", | ||
"@pika/pack": "^0.5.0", | ||
"@pika/plugin-build-node": "^0.9.2", | ||
"@pika/plugin-build-types": "^0.9.2", | ||
"@pika/plugin-copy-assets": "^0.9.2", | ||
"@pika/plugin-standard-pkg": "^0.9.2", | ||
"abort-controller": "^3.0.0", | ||
"abortcontroller-polyfill": "^1.4.0", | ||
"chai": "^4.2.0", | ||
"chai-as-promised": "^7.1.1", | ||
"chai-iterator": "^3.0.2", | ||
"chai-string": "^1.5.0", | ||
"codecov": "^3.6.5", | ||
"cross-env": "^7.0.2", | ||
"form-data": "^3.0.0", | ||
"mocha": "^7.1.0", | ||
"nyc": "^15.0.0", | ||
"parted": "^0.1.1", | ||
"promise": "^8.1.0", | ||
"resumer": "0.0.0", | ||
"string-to-arraybuffer": "^1.0.2", | ||
"xo": "^0.27.2" | ||
}, | ||
"dependencies": { | ||
"data-uri-to-buffer": "^3.0.0", | ||
"fetch-blob": "^1.0.5", | ||
"utf8": "^3.0.0" | ||
}, | ||
"@pika/pack": { | ||
"pipeline": [ | ||
[ | ||
"@pika/plugin-standard-pkg" | ||
], | ||
[ | ||
"@pika/plugin-build-node" | ||
], | ||
[ | ||
"@pika/plugin-build-types" | ||
], | ||
[ | ||
"@pika/plugin-copy-assets", | ||
{ | ||
"files": [ | ||
"externals.d.ts" | ||
] | ||
} | ||
] | ||
] | ||
}, | ||
"xo": { | ||
"envs": [ | ||
"node", | ||
"browser" | ||
], | ||
"rules": { | ||
"valid-jsdoc": 0, | ||
"no-multi-assign": 0, | ||
"complexity": 0, | ||
"unicorn/prefer-spread": 0, | ||
"promise/prefer-await-to-then": 0, | ||
"no-mixed-operators": 0, | ||
"eqeqeq": 0, | ||
"no-eq-null": 0, | ||
"no-negated-condition": 0, | ||
"prefer-named-capture-group": 0, | ||
"unicorn/catch-error-name": 0, | ||
"node/no-deprecated-api": 1 | ||
}, | ||
"ignores": [ | ||
"dist" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": "test/**/*.js", | ||
"envs": [ | ||
"node", | ||
"mocha" | ||
], | ||
"rules": { | ||
"max-nested-callbacks": 0, | ||
"no-unused-expressions": 0, | ||
"eslint-comments/no-unused-disable": 0, | ||
"new-cap": 0, | ||
"guard-for-in": 0, | ||
"no-new": 0 | ||
} | ||
}, | ||
{ | ||
"files": "example.js", | ||
"rules": { | ||
"import/no-extraneous-dependencies": 0 | ||
} | ||
} | ||
] | ||
}, | ||
"babel": { | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": true | ||
} | ||
} | ||
] | ||
] | ||
}, | ||
"nyc": { | ||
"require": [ | ||
"@babel/register" | ||
], | ||
"sourceMap": false, | ||
"instrument": false | ||
}, | ||
"runkitExampleFilename": "example.js" | ||
} | ||
"name": "node-fetch", | ||
"version": "2.6.0", | ||
"description": "A light-weight module that brings window.fetch to node.js", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
"src/**/*", | ||
"dist/**/*", | ||
"types/**/*.d.ts" | ||
], | ||
"engines": { | ||
"node": ">=10.0.0" | ||
}, | ||
"scripts": { | ||
"build": "pika-pack --out dist/", | ||
"prepare": "npm run build", | ||
"test": "cross-env BABEL_ENV=test mocha --require @babel/register --throw-deprecation test/*.js", | ||
"report": "cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/*.js", | ||
"coverage": "cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/*.js && codecov -f coverage/coverage-final.json", | ||
"lint": "xo" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/node-fetch/node-fetch.git" | ||
}, | ||
"keywords": [ | ||
"fetch", | ||
"http", | ||
"promise" | ||
], | ||
"author": "David Frank", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/node-fetch/node-fetch/issues" | ||
}, | ||
"homepage": "https://github.com/node-fetch/node-fetch", | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/node-fetch" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.8.4", | ||
"@babel/preset-env": "^7.8.4", | ||
"@babel/register": "^7.8.3", | ||
"@pika/pack": "^0.5.0", | ||
"@pika/plugin-build-node": "^0.8.1", | ||
"@pika/plugin-build-types": "^0.9.2", | ||
"@pika/plugin-copy-assets": "^0.8.1", | ||
"@pika/plugin-standard-pkg": "^0.9.2", | ||
"abort-controller": "^3.0.0", | ||
"abortcontroller-polyfill": "^1.3.0", | ||
"chai": "^4.2.0", | ||
"chai-as-promised": "^7.1.1", | ||
"chai-iterator": "^3.0.2", | ||
"chai-string": "^1.5.0", | ||
"codecov": "^3.6.4", | ||
"cross-env": "^7.0.0", | ||
"form-data": "^3.0.0", | ||
"mocha": "^7.0.0", | ||
"nyc": "^15.0.0", | ||
"parted": "^0.1.1", | ||
"promise": "^8.0.3", | ||
"resumer": "0.0.0", | ||
"string-to-arraybuffer": "^1.0.2", | ||
"xo": "^0.26.1" | ||
}, | ||
"dependencies": { | ||
"data-uri-to-buffer": "^3.0.0", | ||
"fetch-blob": "^1.0.5" | ||
}, | ||
"@pika/pack": { | ||
"pipeline": [ | ||
[ | ||
"@pika/plugin-standard-pkg" | ||
], | ||
[ | ||
"@pika/plugin-build-node" | ||
], | ||
[ | ||
"@pika/plugin-build-types" | ||
], | ||
[ | ||
"@pika/plugin-copy-assets", | ||
{ | ||
"files": [ | ||
"externals.d.ts" | ||
] | ||
} | ||
] | ||
] | ||
}, | ||
"xo": { | ||
"envs": [ | ||
"node", | ||
"browser" | ||
], | ||
"rules": { | ||
"complexity": 0, | ||
"promise/prefer-await-to-then": 0, | ||
"no-mixed-operators": 0, | ||
"no-negated-condition": 0 | ||
}, | ||
"ignores": [ | ||
"dist" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": "test/**/*.js", | ||
"envs": [ | ||
"node", | ||
"mocha" | ||
], | ||
"rules": { | ||
"max-nested-callbacks": 0, | ||
"no-unused-expressions": 0, | ||
"new-cap": 0, | ||
"guard-for-in": 0 | ||
} | ||
}, | ||
{ | ||
"files": "example.js", | ||
"rules": { | ||
"import/no-extraneous-dependencies": 0 | ||
} | ||
} | ||
] | ||
}, | ||
"babel": { | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": true | ||
} | ||
} | ||
] | ||
] | ||
}, | ||
"nyc": { | ||
"require": [ | ||
"@babel/register" | ||
], | ||
"sourceMap": false, | ||
"instrument": false | ||
}, | ||
"runkitExampleFilename": "example.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ export default function Body(body, { | |
size = 0, | ||
timeout = 0 | ||
} = {}) { | ||
if (body == null) { | ||
if (body === null) { | ||
// Body is undefined or null | ||
body = null; | ||
} else if (isURLSearchParams(body)) { | ||
|
@@ -293,7 +293,7 @@ export function clone(instance, highWaterMark) { | |
*/ | ||
export function extractContentType(body) { | ||
// Body is null or undefined | ||
if (body == null) { | ||
if (body === null) { | ||
Comment on lines
295
to
+296
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment is no longer accurate since this now only checks for This is present in a number of places... |
||
return null; | ||
} | ||
|
||
|
@@ -342,7 +342,7 @@ export function extractContentType(body) { | |
*/ | ||
export function getTotalBytes({body}) { | ||
// Body is null or undefined | ||
if (body == null) { | ||
if (body === null) { | ||
return 0; | ||
} | ||
|
||
|
@@ -373,7 +373,7 @@ export function getTotalBytes({body}) { | |
* @returns {void} | ||
*/ | ||
export function writeToStream(dest, {body}) { | ||
if (body == null) { | ||
if (body === null) { | ||
// Body is null | ||
dest.end(); | ||
} else if (isBlob(body)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt this explanation can be better, something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Just updated the upgrade guide 😄