1'use strict'; 2 3// Tests below are not from WPT. 4 5const common = require('../common'); 6if (!common.hasIntl) { 7 // A handful of the tests fail when ICU is not included. 8 common.skip('missing Intl'); 9} 10 11const util = require('util'); 12const URL = require('url').URL; 13const assert = require('assert'); 14 15const url = new URL('https://username:password@host.name:8080/path/name/?que=ry#hash'); 16 17assert.strictEqual( 18 util.inspect(url), 19 `URL { 20 href: 'https://username:password@host.name:8080/path/name/?que=ry#hash', 21 origin: 'https://host.name:8080', 22 protocol: 'https:', 23 username: 'username', 24 password: 'password', 25 host: 'host.name:8080', 26 hostname: 'host.name', 27 port: '8080', 28 pathname: '/path/name/', 29 search: '?que=ry', 30 searchParams: URLSearchParams { 'que' => 'ry' }, 31 hash: '#hash' 32}`); 33 34assert.strictEqual( 35 util.inspect(url, { showHidden: true }), 36 `URL { 37 href: 'https://username:password@host.name:8080/path/name/?que=ry#hash', 38 origin: 'https://host.name:8080', 39 protocol: 'https:', 40 username: 'username', 41 password: 'password', 42 host: 'host.name:8080', 43 hostname: 'host.name', 44 port: '8080', 45 pathname: '/path/name/', 46 search: '?que=ry', 47 searchParams: URLSearchParams { 'que' => 'ry' }, 48 hash: '#hash', 49 cannotBeBase: false, 50 special: true, 51 [Symbol(context)]: URLContext { 52 flags: 2032, 53 scheme: 'https:', 54 username: 'username', 55 password: 'password', 56 host: 'host.name', 57 port: 8080, 58 path: [ 'path', 'name', '', [length]: 3 ], 59 query: 'que=ry', 60 fragment: 'hash' 61 } 62}`); 63 64assert.strictEqual( 65 util.inspect({ a: url }, { depth: 0 }), 66 '{ a: [URL] }'); 67 68class MyURL extends URL {} 69assert(util.inspect(new MyURL(url.href)).startsWith('MyURL {')); 70