Skip to content

Commit

Permalink
Merge 2803ea5 into d50d2d8
Browse files Browse the repository at this point in the history
  • Loading branch information
imdkbj committed Sep 29, 2020
2 parents d50d2d8 + 2803ea5 commit bbb2ebf
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions validate.js
Expand Up @@ -22,6 +22,8 @@ var alpha = /^[A-Z]+$/i,
semver = /^v?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/,
unixPath = /^((?:\/[a-zA-Z0-9\.\:]+(?:_[a-zA-Z0-9\:\.]+)*(?:\-[\:a-zA-Z0-9\.]+)*)+\/?)$/,
winPath = /^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$/;
url = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{1,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/g;


// https://en.wikipedia.org/wiki/Universally_unique_identifier#Definition
var uuid = {
Expand Down Expand Up @@ -1797,6 +1799,25 @@ function isRGBColor(str) {
return rgbColor.test(str);
}

// ************************************************************************************************
//
// isURL
//
// Check if the string is a URL
//
// Examples :
// isURL('https://google.com') //returns true
// isURL('http://google.com/abcdxyz') //returns true
// isURL('xyz') // returns false
//
// ************************************************************************************************
function isURL(str) {
if (isString(str))
return url.test(str);

return false;
}


// ************************************************************************************************
//
Expand Down Expand Up @@ -1892,7 +1913,8 @@ exports = module.exports = {
isWhiteSpace : isWhiteSpace,
isWinFilePath : isWinFilePath,
objectEquals : objectEquals,
startsWith : startsWith
startsWith : startsWith,
isURL : isURL
};

//
Expand Down Expand Up @@ -2019,4 +2041,4 @@ var SYSTEM_ERROR_CODES = {
'EWOULDBLOCK' : true,
'EXDEV' : true,
'EXFULL' : true
};
};

0 comments on commit bbb2ebf

Please sign in to comment.