@basemaps/lambda-tiler 6.40.0 → 6.41.0

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 (60) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/build/__tests__/wmts.capability.test.js +98 -65
  3. package/build/__tests__/wmts.capability.test.js.map +1 -1
  4. package/build/cli/render.tile.js +13 -10
  5. package/build/cli/render.tile.js.map +1 -1
  6. package/build/routes/__tests__/attribution.test.js +2 -2
  7. package/build/routes/__tests__/attribution.test.js.map +1 -1
  8. package/build/routes/attribution.d.ts +1 -2
  9. package/build/routes/attribution.d.ts.map +1 -1
  10. package/build/routes/attribution.js +16 -14
  11. package/build/routes/attribution.js.map +1 -1
  12. package/build/routes/tile.wmts.d.ts.map +1 -1
  13. package/build/routes/tile.wmts.js +11 -8
  14. package/build/routes/tile.wmts.js.map +1 -1
  15. package/build/util/validate.d.ts.map +1 -1
  16. package/build/util/validate.js +4 -3
  17. package/build/util/validate.js.map +1 -1
  18. package/build/wmts.capability.d.ts +58 -28
  19. package/build/wmts.capability.d.ts.map +1 -1
  20. package/build/wmts.capability.js +167 -93
  21. package/build/wmts.capability.js.map +1 -1
  22. package/dist/index.js +110 -82
  23. package/dist/node_modules/.package-lock.json +10 -10
  24. package/dist/node_modules/detect-libc/README.md +4 -1
  25. package/dist/node_modules/detect-libc/index.d.ts +3 -0
  26. package/dist/node_modules/detect-libc/lib/detect-libc.js +105 -4
  27. package/dist/node_modules/detect-libc/lib/filesystem.js +41 -0
  28. package/dist/node_modules/detect-libc/lib/process.js +3 -0
  29. package/dist/node_modules/detect-libc/package.json +7 -3
  30. package/dist/node_modules/node-abi/.github/workflows/semantic.yml +26 -0
  31. package/dist/node_modules/node-abi/abi_registry.json +25 -1
  32. package/dist/node_modules/node-abi/package.json +1 -1
  33. package/dist/node_modules/node-abi/scripts/update-abi-registry.js +2 -2
  34. package/dist/node_modules/semver/README.md +70 -1
  35. package/dist/node_modules/semver/bin/semver.js +16 -2
  36. package/dist/node_modules/semver/classes/comparator.js +39 -34
  37. package/dist/node_modules/semver/classes/range.js +45 -28
  38. package/dist/node_modules/semver/classes/semver.js +32 -17
  39. package/dist/node_modules/semver/functions/coerce.js +1 -1
  40. package/dist/node_modules/semver/functions/diff.js +58 -16
  41. package/dist/node_modules/semver/functions/inc.js +3 -2
  42. package/dist/node_modules/semver/functions/parse.js +5 -22
  43. package/dist/node_modules/semver/index.js +1 -0
  44. package/dist/node_modules/semver/internal/constants.js +20 -2
  45. package/dist/node_modules/semver/internal/parse-options.js +14 -10
  46. package/dist/node_modules/semver/internal/re.js +34 -4
  47. package/dist/node_modules/semver/package.json +8 -7
  48. package/dist/node_modules/semver/ranges/intersects.js +1 -1
  49. package/dist/node_modules/semver/ranges/subset.js +6 -3
  50. package/dist/package-lock.json +11 -11
  51. package/dist/package.json +1 -2
  52. package/package.json +9 -10
  53. package/src/__tests__/wmts.capability.test.ts +110 -65
  54. package/src/cli/render.tile.ts +13 -10
  55. package/src/routes/__tests__/attribution.test.ts +2 -2
  56. package/src/routes/attribution.ts +16 -12
  57. package/src/routes/tile.wmts.ts +12 -7
  58. package/src/util/validate.ts +4 -3
  59. package/src/wmts.capability.ts +209 -121
  60. package/tsconfig.tsbuildinfo +1 -1
@@ -26,9 +26,16 @@ class Range {
26
26
  this.loose = !!options.loose
27
27
  this.includePrerelease = !!options.includePrerelease
28
28
 
29
- // First, split based on boolean or ||
29
+ // First reduce all whitespace as much as possible so we do not have to rely
30
+ // on potentially slow regexes like \s*. This is then stored and used for
31
+ // future error messages as well.
30
32
  this.raw = range
31
- this.set = range
33
+ .trim()
34
+ .split(/\s+/)
35
+ .join(' ')
36
+
37
+ // First, split on ||
38
+ this.set = this.raw
32
39
  .split('||')
33
40
  // map the range to a 2d array of comparators
34
41
  .map(r => this.parseRange(r.trim()))
@@ -38,7 +45,7 @@ class Range {
38
45
  .filter(c => c.length)
39
46
 
40
47
  if (!this.set.length) {
41
- throw new TypeError(`Invalid SemVer Range: ${range}`)
48
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
42
49
  }
43
50
 
44
51
  // if we have any that are not the null set, throw out null sets.
@@ -64,9 +71,7 @@ class Range {
64
71
 
65
72
  format () {
66
73
  this.range = this.set
67
- .map((comps) => {
68
- return comps.join(' ').trim()
69
- })
74
+ .map((comps) => comps.join(' ').trim())
70
75
  .join('||')
71
76
  .trim()
72
77
  return this.range
@@ -77,12 +82,12 @@ class Range {
77
82
  }
78
83
 
79
84
  parseRange (range) {
80
- range = range.trim()
81
-
82
85
  // memoize range parsing for performance.
83
86
  // this is a very hot path, and fully deterministic.
84
- const memoOpts = Object.keys(this.options).join(',')
85
- const memoKey = `parseRange:${memoOpts}:${range}`
87
+ const memoOpts =
88
+ (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
89
+ (this.options.loose && FLAG_LOOSE)
90
+ const memoKey = memoOpts + ':' + range
86
91
  const cached = cache.get(memoKey)
87
92
  if (cached) {
88
93
  return cached
@@ -93,18 +98,18 @@ class Range {
93
98
  const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
94
99
  range = range.replace(hr, hyphenReplace(this.options.includePrerelease))
95
100
  debug('hyphen replace', range)
101
+
96
102
  // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
97
103
  range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
98
104
  debug('comparator trim', range)
99
105
 
100
106
  // `~ 1.2.3` => `~1.2.3`
101
107
  range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
108
+ debug('tilde trim', range)
102
109
 
103
110
  // `^ 1.2.3` => `^1.2.3`
104
111
  range = range.replace(re[t.CARETTRIM], caretTrimReplace)
105
-
106
- // normalize spaces
107
- range = range.split(/\s+/).join(' ')
112
+ debug('caret trim', range)
108
113
 
109
114
  // At this point, the range is completely trimmed and
110
115
  // ready to be split into comparators.
@@ -190,6 +195,7 @@ class Range {
190
195
  return false
191
196
  }
192
197
  }
198
+
193
199
  module.exports = Range
194
200
 
195
201
  const LRU = require('lru-cache')
@@ -200,12 +206,13 @@ const Comparator = require('./comparator')
200
206
  const debug = require('../internal/debug')
201
207
  const SemVer = require('./semver')
202
208
  const {
203
- re,
209
+ safeRe: re,
204
210
  t,
205
211
  comparatorTrimReplace,
206
212
  tildeTrimReplace,
207
213
  caretTrimReplace,
208
214
  } = require('../internal/re')
215
+ const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')
209
216
 
210
217
  const isNullSet = c => c.value === '<0.0.0-0'
211
218
  const isAny = c => c.value === ''
@@ -253,10 +260,13 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
253
260
  // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
254
261
  // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
255
262
  // ~0.0.1 --> >=0.0.1 <0.1.0-0
256
- const replaceTildes = (comp, options) =>
257
- comp.trim().split(/\s+/).map((c) => {
258
- return replaceTilde(c, options)
259
- }).join(' ')
263
+ const replaceTildes = (comp, options) => {
264
+ return comp
265
+ .trim()
266
+ .split(/\s+/)
267
+ .map((c) => replaceTilde(c, options))
268
+ .join(' ')
269
+ }
260
270
 
261
271
  const replaceTilde = (comp, options) => {
262
272
  const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
@@ -294,10 +304,13 @@ const replaceTilde = (comp, options) => {
294
304
  // ^1.2.0 --> >=1.2.0 <2.0.0-0
295
305
  // ^0.0.1 --> >=0.0.1 <0.0.2-0
296
306
  // ^0.1.0 --> >=0.1.0 <0.2.0-0
297
- const replaceCarets = (comp, options) =>
298
- comp.trim().split(/\s+/).map((c) => {
299
- return replaceCaret(c, options)
300
- }).join(' ')
307
+ const replaceCarets = (comp, options) => {
308
+ return comp
309
+ .trim()
310
+ .split(/\s+/)
311
+ .map((c) => replaceCaret(c, options))
312
+ .join(' ')
313
+ }
301
314
 
302
315
  const replaceCaret = (comp, options) => {
303
316
  debug('caret', comp, options)
@@ -354,9 +367,10 @@ const replaceCaret = (comp, options) => {
354
367
 
355
368
  const replaceXRanges = (comp, options) => {
356
369
  debug('replaceXRanges', comp, options)
357
- return comp.split(/\s+/).map((c) => {
358
- return replaceXRange(c, options)
359
- }).join(' ')
370
+ return comp
371
+ .split(/\s+/)
372
+ .map((c) => replaceXRange(c, options))
373
+ .join(' ')
360
374
  }
361
375
 
362
376
  const replaceXRange = (comp, options) => {
@@ -439,12 +453,15 @@ const replaceXRange = (comp, options) => {
439
453
  const replaceStars = (comp, options) => {
440
454
  debug('replaceStars', comp, options)
441
455
  // Looseness is ignored here. star is always as loose as it gets!
442
- return comp.trim().replace(re[t.STAR], '')
456
+ return comp
457
+ .trim()
458
+ .replace(re[t.STAR], '')
443
459
  }
444
460
 
445
461
  const replaceGTE0 = (comp, options) => {
446
462
  debug('replaceGTE0', comp, options)
447
- return comp.trim()
463
+ return comp
464
+ .trim()
448
465
  .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
449
466
  }
450
467
 
@@ -482,7 +499,7 @@ const hyphenReplace = incPr => ($0,
482
499
  to = `<=${to}`
483
500
  }
484
501
 
485
- return (`${from} ${to}`).trim()
502
+ return `${from} ${to}`.trim()
486
503
  }
487
504
 
488
505
  const testSet = (set, version, options) => {
@@ -1,6 +1,6 @@
1
1
  const debug = require('../internal/debug')
2
2
  const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
3
- const { re, t } = require('../internal/re')
3
+ const { safeRe: re, t } = require('../internal/re')
4
4
 
5
5
  const parseOptions = require('../internal/parse-options')
6
6
  const { compareIdentifiers } = require('../internal/identifiers')
@@ -16,7 +16,7 @@ class SemVer {
16
16
  version = version.version
17
17
  }
18
18
  } else if (typeof version !== 'string') {
19
- throw new TypeError(`Invalid Version: ${version}`)
19
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
20
20
  }
21
21
 
22
22
  if (version.length > MAX_LENGTH) {
@@ -175,36 +175,36 @@ class SemVer {
175
175
 
176
176
  // preminor will bump the version up to the next minor release, and immediately
177
177
  // down to pre-release. premajor and prepatch work the same way.
178
- inc (release, identifier) {
178
+ inc (release, identifier, identifierBase) {
179
179
  switch (release) {
180
180
  case 'premajor':
181
181
  this.prerelease.length = 0
182
182
  this.patch = 0
183
183
  this.minor = 0
184
184
  this.major++
185
- this.inc('pre', identifier)
185
+ this.inc('pre', identifier, identifierBase)
186
186
  break
187
187
  case 'preminor':
188
188
  this.prerelease.length = 0
189
189
  this.patch = 0
190
190
  this.minor++
191
- this.inc('pre', identifier)
191
+ this.inc('pre', identifier, identifierBase)
192
192
  break
193
193
  case 'prepatch':
194
194
  // If this is already a prerelease, it will bump to the next version
195
195
  // drop any prereleases that might already exist, since they are not
196
196
  // relevant at this point.
197
197
  this.prerelease.length = 0
198
- this.inc('patch', identifier)
199
- this.inc('pre', identifier)
198
+ this.inc('patch', identifier, identifierBase)
199
+ this.inc('pre', identifier, identifierBase)
200
200
  break
201
201
  // If the input is a non-prerelease version, this acts the same as
202
202
  // prepatch.
203
203
  case 'prerelease':
204
204
  if (this.prerelease.length === 0) {
205
- this.inc('patch', identifier)
205
+ this.inc('patch', identifier, identifierBase)
206
206
  }
207
- this.inc('pre', identifier)
207
+ this.inc('pre', identifier, identifierBase)
208
208
  break
209
209
 
210
210
  case 'major':
@@ -246,9 +246,15 @@ class SemVer {
246
246
  break
247
247
  // This probably shouldn't be used publicly.
248
248
  // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
249
- case 'pre':
249
+ case 'pre': {
250
+ const base = Number(identifierBase) ? 1 : 0
251
+
252
+ if (!identifier && identifierBase === false) {
253
+ throw new Error('invalid increment argument: identifier is empty')
254
+ }
255
+
250
256
  if (this.prerelease.length === 0) {
251
- this.prerelease = [0]
257
+ this.prerelease = [base]
252
258
  } else {
253
259
  let i = this.prerelease.length
254
260
  while (--i >= 0) {
@@ -259,27 +265,36 @@ class SemVer {
259
265
  }
260
266
  if (i === -1) {
261
267
  // didn't increment anything
262
- this.prerelease.push(0)
268
+ if (identifier === this.prerelease.join('.') && identifierBase === false) {
269
+ throw new Error('invalid increment argument: identifier already exists')
270
+ }
271
+ this.prerelease.push(base)
263
272
  }
264
273
  }
265
274
  if (identifier) {
266
275
  // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
267
276
  // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
277
+ let prerelease = [identifier, base]
278
+ if (identifierBase === false) {
279
+ prerelease = [identifier]
280
+ }
268
281
  if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
269
282
  if (isNaN(this.prerelease[1])) {
270
- this.prerelease = [identifier, 0]
283
+ this.prerelease = prerelease
271
284
  }
272
285
  } else {
273
- this.prerelease = [identifier, 0]
286
+ this.prerelease = prerelease
274
287
  }
275
288
  }
276
289
  break
277
-
290
+ }
278
291
  default:
279
292
  throw new Error(`invalid increment argument: ${release}`)
280
293
  }
281
- this.format()
282
- this.raw = this.version
294
+ this.raw = this.format()
295
+ if (this.build.length) {
296
+ this.raw += `+${this.build.join('.')}`
297
+ }
283
298
  return this
284
299
  }
285
300
  }
@@ -1,6 +1,6 @@
1
1
  const SemVer = require('../classes/semver')
2
2
  const parse = require('./parse')
3
- const { re, t } = require('../internal/re')
3
+ const { safeRe: re, t } = require('../internal/re')
4
4
 
5
5
  const coerce = (version, options) => {
6
6
  if (version instanceof SemVer) {
@@ -1,23 +1,65 @@
1
- const parse = require('./parse')
2
- const eq = require('./eq')
1
+ const parse = require('./parse.js')
3
2
 
4
3
  const diff = (version1, version2) => {
5
- if (eq(version1, version2)) {
4
+ const v1 = parse(version1, null, true)
5
+ const v2 = parse(version2, null, true)
6
+ const comparison = v1.compare(v2)
7
+
8
+ if (comparison === 0) {
6
9
  return null
7
- } else {
8
- const v1 = parse(version1)
9
- const v2 = parse(version2)
10
- const hasPre = v1.prerelease.length || v2.prerelease.length
11
- const prefix = hasPre ? 'pre' : ''
12
- const defaultResult = hasPre ? 'prerelease' : ''
13
- for (const key in v1) {
14
- if (key === 'major' || key === 'minor' || key === 'patch') {
15
- if (v1[key] !== v2[key]) {
16
- return prefix + key
17
- }
18
- }
10
+ }
11
+
12
+ const v1Higher = comparison > 0
13
+ const highVersion = v1Higher ? v1 : v2
14
+ const lowVersion = v1Higher ? v2 : v1
15
+ const highHasPre = !!highVersion.prerelease.length
16
+ const lowHasPre = !!lowVersion.prerelease.length
17
+
18
+ if (lowHasPre && !highHasPre) {
19
+ // Going from prerelease -> no prerelease requires some special casing
20
+
21
+ // If the low version has only a major, then it will always be a major
22
+ // Some examples:
23
+ // 1.0.0-1 -> 1.0.0
24
+ // 1.0.0-1 -> 1.1.1
25
+ // 1.0.0-1 -> 2.0.0
26
+ if (!lowVersion.patch && !lowVersion.minor) {
27
+ return 'major'
28
+ }
29
+
30
+ // Otherwise it can be determined by checking the high version
31
+
32
+ if (highVersion.patch) {
33
+ // anything higher than a patch bump would result in the wrong version
34
+ return 'patch'
35
+ }
36
+
37
+ if (highVersion.minor) {
38
+ // anything higher than a minor bump would result in the wrong version
39
+ return 'minor'
19
40
  }
20
- return defaultResult // may be undefined
41
+
42
+ // bumping major/minor/patch all have same result
43
+ return 'major'
44
+ }
45
+
46
+ // add the `pre` prefix if we are going to a prerelease version
47
+ const prefix = highHasPre ? 'pre' : ''
48
+
49
+ if (v1.major !== v2.major) {
50
+ return prefix + 'major'
51
+ }
52
+
53
+ if (v1.minor !== v2.minor) {
54
+ return prefix + 'minor'
55
+ }
56
+
57
+ if (v1.patch !== v2.patch) {
58
+ return prefix + 'patch'
21
59
  }
60
+
61
+ // high and low are preleases
62
+ return 'prerelease'
22
63
  }
64
+
23
65
  module.exports = diff
@@ -1,7 +1,8 @@
1
1
  const SemVer = require('../classes/semver')
2
2
 
3
- const inc = (version, release, options, identifier) => {
3
+ const inc = (version, release, options, identifier, identifierBase) => {
4
4
  if (typeof (options) === 'string') {
5
+ identifierBase = identifier
5
6
  identifier = options
6
7
  options = undefined
7
8
  }
@@ -10,7 +11,7 @@ const inc = (version, release, options, identifier) => {
10
11
  return new SemVer(
11
12
  version instanceof SemVer ? version.version : version,
12
13
  options
13
- ).inc(release, identifier).version
14
+ ).inc(release, identifier, identifierBase).version
14
15
  } catch (er) {
15
16
  return null
16
17
  }
@@ -1,32 +1,15 @@
1
- const { MAX_LENGTH } = require('../internal/constants')
2
- const { re, t } = require('../internal/re')
3
1
  const SemVer = require('../classes/semver')
4
-
5
- const parseOptions = require('../internal/parse-options')
6
- const parse = (version, options) => {
7
- options = parseOptions(options)
8
-
2
+ const parse = (version, options, throwErrors = false) => {
9
3
  if (version instanceof SemVer) {
10
4
  return version
11
5
  }
12
-
13
- if (typeof version !== 'string') {
14
- return null
15
- }
16
-
17
- if (version.length > MAX_LENGTH) {
18
- return null
19
- }
20
-
21
- const r = options.loose ? re[t.LOOSE] : re[t.FULL]
22
- if (!r.test(version)) {
23
- return null
24
- }
25
-
26
6
  try {
27
7
  return new SemVer(version, options)
28
8
  } catch (er) {
29
- return null
9
+ if (!throwErrors) {
10
+ return null
11
+ }
12
+ throw er
30
13
  }
31
14
  }
32
15
 
@@ -83,6 +83,7 @@ module.exports = {
83
83
  src: internalRe.src,
84
84
  tokens: internalRe.t,
85
85
  SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
86
+ RELEASE_TYPES: constants.RELEASE_TYPES,
86
87
  compareIdentifiers: identifiers.compareIdentifiers,
87
88
  rcompareIdentifiers: identifiers.rcompareIdentifiers,
88
89
  }
@@ -9,9 +9,27 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
9
9
  // Max safe segment length for coercion.
10
10
  const MAX_SAFE_COMPONENT_LENGTH = 16
11
11
 
12
+ // Max safe length for a build identifier. The max length minus 6 characters for
13
+ // the shortest version with a build 0.0.0+BUILD.
14
+ const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
15
+
16
+ const RELEASE_TYPES = [
17
+ 'major',
18
+ 'premajor',
19
+ 'minor',
20
+ 'preminor',
21
+ 'patch',
22
+ 'prepatch',
23
+ 'prerelease',
24
+ ]
25
+
12
26
  module.exports = {
13
- SEMVER_SPEC_VERSION,
14
27
  MAX_LENGTH,
15
- MAX_SAFE_INTEGER,
16
28
  MAX_SAFE_COMPONENT_LENGTH,
29
+ MAX_SAFE_BUILD_LENGTH,
30
+ MAX_SAFE_INTEGER,
31
+ RELEASE_TYPES,
32
+ SEMVER_SPEC_VERSION,
33
+ FLAG_INCLUDE_PRERELEASE: 0b001,
34
+ FLAG_LOOSE: 0b010,
17
35
  }
@@ -1,11 +1,15 @@
1
- // parse out just the options we care about so we always get a consistent
2
- // obj with keys in a consistent order.
3
- const opts = ['includePrerelease', 'loose', 'rtl']
4
- const parseOptions = options =>
5
- !options ? {}
6
- : typeof options !== 'object' ? { loose: true }
7
- : opts.filter(k => options[k]).reduce((o, k) => {
8
- o[k] = true
9
- return o
10
- }, {})
1
+ // parse out just the options we care about
2
+ const looseOption = Object.freeze({ loose: true })
3
+ const emptyOpts = Object.freeze({ })
4
+ const parseOptions = options => {
5
+ if (!options) {
6
+ return emptyOpts
7
+ }
8
+
9
+ if (typeof options !== 'object') {
10
+ return looseOption
11
+ }
12
+
13
+ return options
14
+ }
11
15
  module.exports = parseOptions
@@ -1,19 +1,49 @@
1
- const { MAX_SAFE_COMPONENT_LENGTH } = require('./constants')
1
+ const {
2
+ MAX_SAFE_COMPONENT_LENGTH,
3
+ MAX_SAFE_BUILD_LENGTH,
4
+ MAX_LENGTH,
5
+ } = require('./constants')
2
6
  const debug = require('./debug')
3
7
  exports = module.exports = {}
4
8
 
5
9
  // The actual regexps go on exports.re
6
10
  const re = exports.re = []
11
+ const safeRe = exports.safeRe = []
7
12
  const src = exports.src = []
8
13
  const t = exports.t = {}
9
14
  let R = 0
10
15
 
16
+ const LETTERDASHNUMBER = '[a-zA-Z0-9-]'
17
+
18
+ // Replace some greedy regex tokens to prevent regex dos issues. These regex are
19
+ // used internally via the safeRe object since all inputs in this library get
20
+ // normalized first to trim and collapse all extra whitespace. The original
21
+ // regexes are exported for userland consumption and lower level usage. A
22
+ // future breaking change could export the safer regex only with a note that
23
+ // all input should have extra whitespace removed.
24
+ const safeRegexReplacements = [
25
+ ['\\s', 1],
26
+ ['\\d', MAX_LENGTH],
27
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
28
+ ]
29
+
30
+ const makeSafeRegex = (value) => {
31
+ for (const [token, max] of safeRegexReplacements) {
32
+ value = value
33
+ .split(`${token}*`).join(`${token}{0,${max}}`)
34
+ .split(`${token}+`).join(`${token}{1,${max}}`)
35
+ }
36
+ return value
37
+ }
38
+
11
39
  const createToken = (name, value, isGlobal) => {
40
+ const safe = makeSafeRegex(value)
12
41
  const index = R++
13
42
  debug(name, index, value)
14
43
  t[name] = index
15
44
  src[index] = value
16
45
  re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
46
+ safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
17
47
  }
18
48
 
19
49
  // The following Regular Expressions can be used for tokenizing,
@@ -23,13 +53,13 @@ const createToken = (name, value, isGlobal) => {
23
53
  // A single `0`, or a non-zero digit followed by zero or more digits.
24
54
 
25
55
  createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*')
26
- createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+')
56
+ createToken('NUMERICIDENTIFIERLOOSE', '\\d+')
27
57
 
28
58
  // ## Non-numeric Identifier
29
59
  // Zero or more digits, followed by a letter or hyphen, and then zero or
30
60
  // more letters, digits, or hyphens.
31
61
 
32
- createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*')
62
+ createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`)
33
63
 
34
64
  // ## Main Version
35
65
  // Three dot-separated numeric identifiers.
@@ -64,7 +94,7 @@ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
64
94
  // ## Build Metadata Identifier
65
95
  // Any combination of digits, letters, or hyphens.
66
96
 
67
- createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+')
97
+ createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`)
68
98
 
69
99
  // ## Build Metadata
70
100
  // Plus sign, followed by one or more period-separated build metadata
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semver",
3
- "version": "7.3.8",
3
+ "version": "7.5.4",
4
4
  "description": "The semantic version parser used by npm.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -13,8 +13,8 @@
13
13
  "template-oss-apply": "template-oss-apply --force"
14
14
  },
15
15
  "devDependencies": {
16
- "@npmcli/eslint-config": "^3.0.1",
17
- "@npmcli/template-oss": "4.4.4",
16
+ "@npmcli/eslint-config": "^4.0.0",
17
+ "@npmcli/template-oss": "4.17.0",
18
18
  "tap": "^16.0.0"
19
19
  },
20
20
  "license": "ISC",
@@ -37,7 +37,7 @@
37
37
  "range.bnf"
38
38
  ],
39
39
  "tap": {
40
- "check-coverage": true,
40
+ "timeout": 30,
41
41
  "coverage-map": "map.js",
42
42
  "nyc-arg": [
43
43
  "--exclude",
@@ -53,9 +53,8 @@
53
53
  "author": "GitHub Inc.",
54
54
  "templateOSS": {
55
55
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
56
- "version": "4.4.4",
56
+ "version": "4.17.0",
57
57
  "engines": ">=10",
58
- "content": "./scripts",
59
58
  "ciVersions": [
60
59
  "10.0.0",
61
60
  "10.x",
@@ -64,6 +63,7 @@
64
63
  "16.x",
65
64
  "18.x"
66
65
  ],
66
+ "npmSpec": "8",
67
67
  "distPaths": [
68
68
  "classes/",
69
69
  "functions/",
@@ -81,6 +81,7 @@
81
81
  "/index.js",
82
82
  "/preload.js",
83
83
  "/range.bnf"
84
- ]
84
+ ],
85
+ "publish": "true"
85
86
  }
86
87
  }
@@ -2,6 +2,6 @@ const Range = require('../classes/range')
2
2
  const intersects = (r1, r2, options) => {
3
3
  r1 = new Range(r1, options)
4
4
  r2 = new Range(r2, options)
5
- return r1.intersects(r2)
5
+ return r1.intersects(r2, options)
6
6
  }
7
7
  module.exports = intersects
@@ -68,6 +68,9 @@ const subset = (sub, dom, options = {}) => {
68
68
  return true
69
69
  }
70
70
 
71
+ const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')]
72
+ const minimumVersion = [new Comparator('>=0.0.0')]
73
+
71
74
  const simpleSubset = (sub, dom, options) => {
72
75
  if (sub === dom) {
73
76
  return true
@@ -77,9 +80,9 @@ const simpleSubset = (sub, dom, options) => {
77
80
  if (dom.length === 1 && dom[0].semver === ANY) {
78
81
  return true
79
82
  } else if (options.includePrerelease) {
80
- sub = [new Comparator('>=0.0.0-0')]
83
+ sub = minimumVersionWithPreRelease
81
84
  } else {
82
- sub = [new Comparator('>=0.0.0')]
85
+ sub = minimumVersion
83
86
  }
84
87
  }
85
88
 
@@ -87,7 +90,7 @@ const simpleSubset = (sub, dom, options) => {
87
90
  if (options.includePrerelease) {
88
91
  return true
89
92
  } else {
90
- dom = [new Comparator('>=0.0.0')]
93
+ dom = minimumVersion
91
94
  }
92
95
  }
93
96