Skip to content
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

errors, url: migrate to use internal/errors.js #11360

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
url : migrate to use intrenal/errors.js
Bougarfaoui El houcine authored Feb 13, 2017
commit 1384821277bfb4165f6109f163886bb88ca547e2
6 changes: 3 additions & 3 deletions lib/url.js
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ function importPunycode() {

const { toASCII } = importPunycode();

const errors = require('internal/errors');
const internalUrl = require('internal/url');
const encodeAuth = internalUrl.encodeAuth;
exports.parse = urlParse;
@@ -92,7 +93,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {

Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
if (typeof url !== 'string') {
throw new TypeError('Parameter "url" must be a string, not ' + typeof url);
throw new errors.TypeError('ERR_INVALID_ARG_TYPE','url','String',url);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter should complain here, there needs to be a space following the comma. Can you run make lint to check this?

}

// Copy chrome, IE, opera backslash-handling behavior.
@@ -546,8 +547,7 @@ function urlFormat(obj, options) {
if (typeof obj === 'string') {
obj = urlParse(obj);
} else if (typeof obj !== 'object' || obj === null) {
throw new TypeError('Parameter "urlObj" must be an object, not ' +
(obj === null ? 'null' : typeof obj));
throw new errors.TypeError('ERR_INVALID_ARG_TYPE','obj','Object',obj);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

} else if (!(obj instanceof Url)) {
var format = obj[internalUrl.formatSymbol];
return format ?