File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
24
24
*/
25
25
26
26
function isUrl ( string ) {
27
+ if ( typeof string !== 'string' ) {
28
+ return false ;
29
+ }
30
+
27
31
var match = string . match ( protocolAndDomainRE ) ;
28
32
if ( ! match ) {
29
33
return false ;
Original file line number Diff line number Diff line change @@ -118,6 +118,22 @@ describe('is-url', function () {
118
118
it ( 'google.com' , function ( ) {
119
119
assert ( ! url ( 'google.com' ) ) ;
120
120
} ) ;
121
+
122
+ it ( 'empty' , function ( ) {
123
+ assert ( ! url ( '' ) ) ;
124
+ } ) ;
125
+
126
+ it ( 'undef' , function ( ) {
127
+ assert ( ! url ( undefined ) ) ;
128
+ } ) ;
129
+
130
+ it ( 'object' , function ( ) {
131
+ assert ( ! url ( { } ) ) ;
132
+ } ) ;
133
+
134
+ it ( 're' , function ( ) {
135
+ assert ( ! url ( / a b c / ) ) ;
136
+ } ) ;
121
137
} ) ;
122
138
123
139
describe ( 'redos' , function ( ) {
You can’t perform that action at this time.
0 commit comments