24 lines
299 B
JavaScript
24 lines
299 B
JavaScript
|
|
||
|
/**
|
||
|
* Expose `isUrl`.
|
||
|
*/
|
||
|
|
||
|
module.exports = isUrl;
|
||
|
|
||
|
/**
|
||
|
* Matcher.
|
||
|
*/
|
||
|
|
||
|
var matcher = /^(?:\w+:)?\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/;
|
||
|
|
||
|
/**
|
||
|
* Loosely validate a URL `string`.
|
||
|
*
|
||
|
* @param {String} string
|
||
|
* @return {Boolean}
|
||
|
*/
|
||
|
|
||
|
function isUrl(string){
|
||
|
return matcher.test(string);
|
||
|
}
|