You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would recommend simply returning * if any of the components are *, like such:
Consider that *doesn't match (by design) 1.0.0-prerelease. So, * || 1.0.0-prerelease is different than *.
validRange('* || 1.0.0') // bad: '||1.0.0'
Since a blank range is equivalent to *, ||1.0.0-prerelease actually is identical to * || 1.0.0-prerelease.
I agree that it would be nice to omit identical ranges that exist between || characters. Thus *||* would reduce to || and then merely a blank line, which would be replaced by * (which is there to support checks that do if(validRange(...)) and expect null to be the only non-truthy return value). We could also remove ranges in the set that don't have any prerelease parts if there's a *. Patches welcome for those enhancements.
But what's there now is not semantically incorrect, and is working as intended.
Activity
[-]validRange doesn't format asterisks correctly[/-][+]validRange doesn't format x-ranges correctly[/+]isaacs commentedon Jan 30, 2017
But those aren't actually identical.
Consider that
*doesn't match (by design)1.0.0-prerelease. So,* || 1.0.0-prereleaseis different than*.Since a blank range is equivalent to
*,||1.0.0-prereleaseactually is identical to* || 1.0.0-prerelease.I agree that it would be nice to omit identical ranges that exist between
||characters. Thus*||*would reduce to||and then merely a blank line, which would be replaced by*(which is there to support checks that doif(validRange(...))and expectnullto be the only non-truthy return value). We could also remove ranges in the set that don't have any prerelease parts if there's a*. Patches welcome for those enhancements.But what's there now is not semantically incorrect, and is working as intended.