From 664d4d26ed757b750c4e2a68978647494ebd9360 Mon Sep 17 00:00:00 2001 From: Junshu Okamoto Date: Fri, 7 Oct 2016 13:02:12 -0700 Subject: [PATCH 1/3] test: expand test coverage for url.js Currently Line 309 of lib/url.js is not reachable from test-url because there are no examples which has more than 255 characters in the hostname of the url. I added one example which can reach that line. --- test/parallel/test-url.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js index 12c3178fb9a8e2..dcd499972e2df5 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -999,6 +999,10 @@ for (const u in parseTestsWithQueryString) { // some extra formatting tests, just to verify // that it'll format slightly wonky content to a valid url. + +// Example of url which has more than 255 characters in hostname and excesses the limit. +const excessHostnameUrl = 'http://' + 'a'.repeat(255) + '.com/node'; + var formatTests = { 'http://example.com?': { href: 'http://example.com/?', @@ -1200,6 +1204,17 @@ var formatTests = { pathname: '/' }, + // more than 255 characters in hostname which excesses the limit + [excessHostnameUrl]: { + href: 'http:///node', + protocol: 'http:', + slashes: true, + host: '', + hostname: '', + pathname: '/node', + path: '/node' + }, + // https://github.com/nodejs/node/issues/3361 'file:///home/user': { href: 'file:///home/user', From 8280e54a9064e6b1bb2b87a182e44a24559f82dc Mon Sep 17 00:00:00 2001 From: Junshu Okamoto Date: Fri, 7 Oct 2016 14:02:25 -0700 Subject: [PATCH 2/3] test: get rid of excessHostnameUrl const delete excessHostnameUrl and add exceeded hostname url directly. --- test/parallel/test-url.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js index dcd499972e2df5..12d9b200fd3cda 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -1000,9 +1000,6 @@ for (const u in parseTestsWithQueryString) { // some extra formatting tests, just to verify // that it'll format slightly wonky content to a valid url. -// Example of url which has more than 255 characters in hostname and excesses the limit. -const excessHostnameUrl = 'http://' + 'a'.repeat(255) + '.com/node'; - var formatTests = { 'http://example.com?': { href: 'http://example.com/?', @@ -1204,8 +1201,8 @@ var formatTests = { pathname: '/' }, - // more than 255 characters in hostname which excesses the limit - [excessHostnameUrl]: { + // more than 255 characters in hostname which exceeds the limit + [`http://${'a'.repeat(255)}.com/node`]: { href: 'http:///node', protocol: 'http:', slashes: true, From 48c54746e8e65b2a83b972cc77cc89540e236619 Mon Sep 17 00:00:00 2001 From: Junshu Okamoto Date: Fri, 7 Oct 2016 14:23:04 -0700 Subject: [PATCH 3/3] test: delete unnecessary empty line --- test/parallel/test-url.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js index 12d9b200fd3cda..8bbc7194732368 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -999,7 +999,6 @@ for (const u in parseTestsWithQueryString) { // some extra formatting tests, just to verify // that it'll format slightly wonky content to a valid url. - var formatTests = { 'http://example.com?': { href: 'http://example.com/?',