semver icon indicating copy to clipboard operation
semver copied to clipboard

NewRange does not like `>=3.0.0 <=3.193.0 || >3.196.0 <3.377.0 || >3.377.0`

Open jsumners-nr opened this issue 9 months ago • 2 comments

Trying to parse >=3.0.0 <=3.193.0 || >3.196.0 <3.377.0 || >3.377.0 with NewVersion results in the error "Given string does not resemble a Version". This is a possible version string according to https://docs.npmjs.com/cli/v6/using-npm/semver#advanced-range-syntax.

jsumners-nr avatar May 01 '24 19:05 jsumners-nr

Hey James, alternates (conjunctiv, disjunctive) are not implemented, nor am I going to do so.

The reason for that is, one should be using a SAT-solver when it comes to that complexity – or for trivial cases implement Contains and IsSatisfiedBy for predicates AND, OR.

Though now with more experience, I’m open to rewrite the package to be easier usable with interfaces. If that’d move you forward say so and I’ll release a new version.

mark-kubacki avatar May 02 '24 15:05 mark-kubacki

Though now with more experience, I’m open to rewrite the package to be easier usable with interfaces. If that’d move you forward say so and I’ll release a new version.

I don't follow the idea. Can you provide an example?

Also, I discovered this morning that semver.NewRange will fail to parse >=1.0.0 <2.0.0 due to the trailing space character.

jsumners-nr avatar May 02 '24 15:05 jsumners-nr

Input sanitation is out of scope of this library.

Interfaces are sth. like this in Go: interface { Contains(v Version) bool }
… and can only be implemented on pointer receiver(s) like func (v *Semver) Contains(v Version) bool {…}

Anyway, I’ll close this for now since the original use-case is clarified.

mark-kubacki avatar May 08 '24 15:05 mark-kubacki