diff --git a/packages/handy-url/package.json b/packages/handy-url/package.json index 3ad6db8..b6998d7 100644 --- a/packages/handy-url/package.json +++ b/packages/handy-url/package.json @@ -20,8 +20,8 @@ ], "dependencies": { "jolt-lodash": "^2.7.7", - "qs": "6.2.0", - "url-parse": "1.1.1", + "qs": "6.5.1", + "url-parse": "1.1.9", "valid-url": "1.0.9" }, "scripts": { diff --git a/packages/handy-url/src/Url.js b/packages/handy-url/src/Url.js index d276a85..425fefe 100644 --- a/packages/handy-url/src/Url.js +++ b/packages/handy-url/src/Url.js @@ -164,9 +164,11 @@ class Url { const {protocol} = this.parsed; switch (protocol) { - // If the url doesn't have a protocol, the parse(url) method returns - // `about` for `about:blank`. + case '': + return null; case 'about:': + // If the url doesn't have a protocol, the parse(url) method returns + // `about` for `about:blank`. return null; default: // We want to remote the colon from the end of the protocol. diff --git a/packages/handy-url/src/__tests__/Url.spec.js b/packages/handy-url/src/__tests__/Url.spec.js index ef3970d..915e292 100644 --- a/packages/handy-url/src/__tests__/Url.spec.js +++ b/packages/handy-url/src/__tests__/Url.spec.js @@ -1,10 +1,3 @@ -/** - * @jest-environment jsdom - * - * TODO(mark): Unsure why this is necessary but in a node environment, tests - * fail. Definitely has to do with the Url class. - */ - // Imports import Url from '../Url'; @@ -127,8 +120,12 @@ describe('Url', () => { expect(new Url('https://google.com').domain).toBe('google'); }); - it('does not require a protocol', () => { - expect(new Url('www.google.com').domain).toBe('google'); + it('does not require a protocol but requires slashes', () => { + expect(new Url('//www.google.com').domain).toBe('google'); + }); + + it('returns the empty string for invalid urls', () => { + expect(new Url('www.google.com').domain).toBe(''); }); }); diff --git a/yarn.lock b/yarn.lock index c33bb0e..a951275 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3767,9 +3767,9 @@ q@^1.4.1: version "1.5.0" resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1" -qs@6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.0.tgz#3b7848c03c2dece69a9522b0fae8c4126d745f3b" +qs@6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" qs@~6.3.0: version "6.3.2" @@ -3779,9 +3779,9 @@ qs@~6.4.0: version "6.4.0" resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" -querystringify@0.0.x: - version "0.0.4" - resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-0.0.4.tgz#0cf7f84f9463ff0ae51c4c4b142d95be37724d9c" +querystringify@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-1.0.0.tgz#6286242112c5b712fa654e526652bf6a13ff05cb" randomatic@^1.1.3: version "1.1.7" @@ -4550,11 +4550,11 @@ universalify@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7" -url-parse@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.1.tgz#d1507970728c9a5f80f471530c57325c3fb0e868" +url-parse@1.1.9: + version "1.1.9" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.9.tgz#c67f1d775d51f0a18911dd7b3ffad27bb9e5bd19" dependencies: - querystringify "0.0.x" + querystringify "~1.0.0" requires-port "1.0.x" user-home@^1.1.1: