Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions validate.js
Original file line number Diff line number Diff line change
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
};
};