2017-01-28 10:23:47 +01:00
|
|
|
'use strict';
|
2017-06-28 18:12:12 +02:00
|
|
|
const common = require('../common');
|
2017-01-28 10:23:47 +01:00
|
|
|
const assert = require('assert');
|
|
|
|
const url = require('url');
|
|
|
|
|
|
|
|
// https://github.com/joyent/node/issues/568
|
|
|
|
[
|
2017-06-28 18:12:12 +02:00
|
|
|
[undefined, 'undefined'],
|
|
|
|
[null, 'null'],
|
|
|
|
[true, 'boolean'],
|
|
|
|
[false, 'boolean'],
|
|
|
|
[0.0, 'number'],
|
|
|
|
[0, 'number'],
|
|
|
|
[[], 'object'],
|
|
|
|
[{}, 'object'],
|
|
|
|
[() => {}, 'function'],
|
|
|
|
[Symbol('foo'), 'symbol']
|
|
|
|
].forEach(([val, type]) => {
|
|
|
|
const error = common.expectsError({
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
|
|
type: TypeError,
|
|
|
|
message: `The "url" argument must be of type string. Received type ${type}`
|
|
|
|
});
|
|
|
|
assert.throws(() => { url.parse(val); }, error);
|
2017-01-28 10:23:47 +01:00
|
|
|
});
|
2017-03-30 14:21:49 +02:00
|
|
|
|
2017-05-07 13:12:30 +02:00
|
|
|
assert.throws(() => { url.parse('http://%E0%A4%A@fail'); },
|
|
|
|
/^URIError: URI malformed$/);
|