url: add inspect function to TupleOrigin
This adds a simple inspect function the the TupleOrigin class. This adds tests for the newly added inspect function in the TupleOrigin class. PR-URL: https://github.com/nodejs/node/pull/10039 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
This commit is contained in:
parent
38ed3fb14f
commit
883173289d
@ -69,6 +69,15 @@ class TupleOrigin {
|
||||
result += `:${this.port}`;
|
||||
return result;
|
||||
}
|
||||
|
||||
inspect() {
|
||||
return `TupleOrigin {
|
||||
scheme: ${this.scheme},
|
||||
host: ${this.host},
|
||||
port: ${this.port},
|
||||
domain: ${this.domain}
|
||||
}`;
|
||||
}
|
||||
}
|
||||
|
||||
class URL {
|
||||
|
37
test/parallel/test-util-inspect-tuple-origin.js
Normal file
37
test/parallel/test-util-inspect-tuple-origin.js
Normal file
@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const inspect = require('util').inspect;
|
||||
const URL = require('url').URL;
|
||||
|
||||
assert.strictEqual(
|
||||
inspect(URL.originFor('http://test.com:8000')),
|
||||
`TupleOrigin {
|
||||
scheme: http,
|
||||
host: test.com,
|
||||
port: 8000,
|
||||
domain: null
|
||||
}`
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
inspect(URL.originFor('http://test.com')),
|
||||
`TupleOrigin {
|
||||
scheme: http,
|
||||
host: test.com,
|
||||
port: undefined,
|
||||
domain: null
|
||||
}`
|
||||
);
|
||||
|
||||
|
||||
assert.strictEqual(
|
||||
inspect(URL.originFor('https://test.com')),
|
||||
`TupleOrigin {
|
||||
scheme: https,
|
||||
host: test.com,
|
||||
port: undefined,
|
||||
domain: null
|
||||
}`
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user