OCA_Backend/api/node_modules/validator/es/lib/isSemVer.js

14 lines
597 B
JavaScript
Raw Permalink Normal View History

2022-01-22 13:36:44 +00:00
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);
}