From c6b324ea319c7f0eb887b10ca63211b2aa705bc6 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 1 Dec 2016 11:23:46 -0600 Subject: [PATCH 1/4] url: add inspect function to TupleOrigin This adds a simple inspect function the the TupleOrigin class. --- lib/internal/url.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/internal/url.js b/lib/internal/url.js index 79b9e1cb0f46bb..05be3ac7e8b9ec 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -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 { From b9306532ecc09622257814b5ab3c814232029a37 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 1 Dec 2016 11:44:32 -0600 Subject: [PATCH 2/4] test: add test for inspect in TupleOrigin This adds tests for the newly added inspect function in the TupleOrigin class. --- .../test-util-inspect-tuple-origin.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/parallel/test-util-inspect-tuple-origin.js diff --git a/test/parallel/test-util-inspect-tuple-origin.js b/test/parallel/test-util-inspect-tuple-origin.js new file mode 100644 index 00000000000000..5d17a66271c16d --- /dev/null +++ b/test/parallel/test-util-inspect-tuple-origin.js @@ -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 + }` + ); From d2a35cb74374d72422b92fa2f4a40e38557266db Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Fri, 2 Dec 2016 12:37:36 -0600 Subject: [PATCH 3/4] url: fix spacing in inspect string --- lib/internal/url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index 05be3ac7e8b9ec..e19b546a1b237e 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -71,7 +71,7 @@ class TupleOrigin { } inspect() { - return `TupleOrigin{ + return `TupleOrigin { scheme: ${this.scheme}, host: ${this.host}, port: ${this.port}, From 79a9b532c3450feb64dd14a1cfa16606ff28aee0 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Fri, 2 Dec 2016 17:11:07 -0600 Subject: [PATCH 4/4] test: update tests to match new format --- test/parallel/test-util-inspect-tuple-origin.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-util-inspect-tuple-origin.js b/test/parallel/test-util-inspect-tuple-origin.js index 5d17a66271c16d..7529273756afe9 100644 --- a/test/parallel/test-util-inspect-tuple-origin.js +++ b/test/parallel/test-util-inspect-tuple-origin.js @@ -7,7 +7,7 @@ const URL = require('url').URL; assert.strictEqual( inspect(URL.originFor('http://test.com:8000')), - `TupleOrigin{ + `TupleOrigin { scheme: http, host: test.com, port: 8000, @@ -17,7 +17,7 @@ assert.strictEqual( assert.strictEqual( inspect(URL.originFor('http://test.com')), - `TupleOrigin{ + `TupleOrigin { scheme: http, host: test.com, port: undefined, @@ -28,7 +28,7 @@ assert.strictEqual( assert.strictEqual( inspect(URL.originFor('https://test.com')), - `TupleOrigin{ + `TupleOrigin { scheme: https, host: test.com, port: undefined,