You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
597 B
14 lines
597 B
2 years ago
|
import assertString from './util/assertString';
|
||
|
import multilineRegexp from './util/multilineRegex';
|
||
|
/**
|
||
|
* Regular Expression to match
|
||
|
* semantic versioning (SemVer)
|
||
|
* built from multi-line, multi-parts regexp
|
||
|
* Reference: https://semver.org/
|
||
|
*/
|
||
|
|
||
|
var semanticVersioningRegex = multilineRegexp(['^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)', '(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))', '?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$'], 'i');
|
||
|
export default function isSemVer(str) {
|
||
|
assertString(str);
|
||
|
return semanticVersioningRegex.test(str);
|
||
|
}
|