summaryrefslogtreecommitdiff
path: root/src/node_modules/validator/es/lib/isSemVer.js
blob: d9b51eb5ec50f0e1e30c6e9704663ef65bb7258e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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-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-]+)*))?$']);
export default function isSemVer(str) {
  assertString(str);
  return semanticVersioningRegex.test(str);
}