semver 6.1.0 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +16 -0
  2. package/package.json +1 -1
  3. package/semver.js +6 -2
package/README.md CHANGED
@@ -412,3 +412,19 @@ The maximum length for any semver component considered for coercion is 16 chara
412
412
  longer components will be ignored (`10000000000000000.4.7.4` becomes `4.7.4`).
413
413
  The maximum value for any semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`;
414
414
  higher value components are invalid (`9999999999999999.4.7.4` is likely invalid).
415
+
416
+ ### Clean
417
+
418
+ * `clean(version)`: Clean a string to be a valid semver if possible
419
+
420
+ This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
421
+
422
+ ex.
423
+ * `s.clean(' = v 2.1.5foo')`: `null`
424
+ * `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
425
+ * `s.clean(' = v 2.1.5-foo')`: `null`
426
+ * `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
427
+ * `s.clean('=v2.1.5')`: `'2.1.5'`
428
+ * `s.clean(' =v2.1.5')`: `2.1.5`
429
+ * `s.clean(' 2.1.5 ')`: `'2.1.5'`
430
+ * `s.clean('~1.0.0')`: `null`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semver",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "description": "The semantic version parser used by npm.",
5
5
  "main": "semver.js",
6
6
  "scripts": {
package/semver.js CHANGED
@@ -1256,6 +1256,10 @@ function hyphenReplace ($0,
1256
1256
 
1257
1257
  // if ANY of the sets match ALL of its comparators, then pass
1258
1258
  Range.prototype.test = function (version) {
1259
+ if (!version) {
1260
+ return false
1261
+ }
1262
+
1259
1263
  if (typeof version === 'string') {
1260
1264
  version = new SemVer(version, this.options)
1261
1265
  }
@@ -1519,7 +1523,7 @@ function intersects (r1, r2, options) {
1519
1523
  }
1520
1524
 
1521
1525
  exports.coerce = coerce
1522
- function coerce (version) {
1526
+ function coerce (version, options) {
1523
1527
  if (version instanceof SemVer) {
1524
1528
  return version
1525
1529
  }
@@ -1536,5 +1540,5 @@ function coerce (version) {
1536
1540
 
1537
1541
  return parse(match[1] +
1538
1542
  '.' + (match[2] || '0') +
1539
- '.' + (match[3] || '0'))
1543
+ '.' + (match[3] || '0'), options)
1540
1544
  }