Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
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
9 changes: 9 additions & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ class TupleOrigin {
result += `:${this.port}`;
return result;
}

inspect() {
return `TupleOrigin{
Copy link
Member

Choose a reason for hiding this comment

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

I think we have spaces before the { in most cases here?

scheme: ${this.scheme},
host: ${this.host},
port: ${this.port},
domain: ${this.domain}
}`;
}
}

class URL {
Expand Down
37 changes: 37 additions & 0 deletions test/parallel/test-util-inspect-tuple-origin.js
Original file line number Diff line number Diff line change
@@ -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
}`
);