diff --git a/index.js b/index.js index 1d3e349..3ea3d20 100644 --- a/index.js +++ b/index.js @@ -24,6 +24,10 @@ var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/; */ function isUrl(string){ + if (typeof string !== 'string') { + return false; + } + var match = string.match(protocolAndDomainRE); if (!match) { return false; diff --git a/test/index.js b/test/index.js index 52cfacb..404e1b6 100644 --- a/test/index.js +++ b/test/index.js @@ -118,6 +118,22 @@ describe('is-url', function () { it('google.com', function () { assert(!url('google.com')); }); + + it('empty', function () { + assert(!url('')); + }); + + it('undef', function () { + assert(!url(undefined)); + }); + + it('object', function () { + assert(!url({})); + }); + + it('re', function () { + assert(!url(/abc/)); + }); }); describe('redos', function () {