Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions classes/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ const isSatisfiable = (comparators, options) => {
// already replaced the hyphen ranges
// turn into a set of JUST comparators.
const parseComparator = (comp, options) => {
comp = comp.replace(re[t.BUILD], '')
debug('comp', comp, options)
comp = replaceCarets(comp, options)
debug('caret', comp)
Expand Down
46 changes: 46 additions & 0 deletions test/classes/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,49 @@ test('cache', (t) => {
t.equal(r2.set[0][cached], true) // Will be true, showing it's cached.
t.end()
})

test('Build metadata is allowed and ignored for X-ranges and partials', t => {
const buildCases = [
'1.x.x+build >2.x+build',
'>=1.x+build <2.x.x+build',
'1.x.x+build || 2.x.x+build',
'1.x+build.123',
'1.x.x+meta-data',
'1.x.x+build.123 >2.x.x+meta-data',
'1.x.x+build <2.x.x+meta',
'>1.x+build <=2.x.x+meta',
' 1.x.x+build >2.x.x+build ',
'^1.x+build',
'^1.x.x+build',
'^1.2.x+build',
'^1.x+meta-data',
'^1.x.x+build.123',
'~1.x+build',
'~1.x.x+build',
'~1.2.x+build',
'~1.x+meta-data',
'~1.x.x+build.123',
'^1.x.x+build || ~2.x.x+meta',
'~1.x.x+build >2.x+meta',
'^1.x+build.123 <2.x.x+meta-data',
]
t.plan(buildCases.length)
buildCases.forEach(range => {
t.doesNotThrow(() => new Range(range), `${range} should not throw`)
})
t.end()
})

test('Build metadata with prerelease in X-ranges/partials', t => {
const cases = [
'1.x.x-alpha+build',
'>1.x.x-alpha+build',
'>=1.x.x-alpha+build <2.x.x+build',
'1.x.x-alpha+build || 2.x.x+build',
]
t.plan(cases.length)
cases.forEach(range => {
t.doesNotThrow(() => new Range(range), TypeError, `${range} should not throw`)
})
t.end()
})
Loading