isSemVer.js 949 B

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isSemVer;
  6. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7. var _multilineRegex = _interopRequireDefault(require("./util/multilineRegex"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * Regular Expression to match
  11. * semantic versioning (SemVer)
  12. * built from multi-line, multi-parts regexp
  13. * Reference: https://semver.org/
  14. */
  15. var semanticVersioningRegex = (0, _multilineRegex.default)(['^(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');
  16. function isSemVer(str) {
  17. (0, _assertString.default)(str);
  18. return semanticVersioningRegex.test(str);
  19. }
  20. module.exports = exports.default;
  21. module.exports.default = exports.default;