-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid NPM block #99
Comments
Reading the NPM grammar, the version is invalid: range ::= hyphen | simple ( ' ' simple ) * | ''
simple ::= primitive | partial | tilde | caret A A primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial So: a comparator, immediately attached to a A partial is: partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
qualifier ::= ( '-' pre )? ( '+' build )? I suggest raising the issue with the developer of that package ;) |
It seems what they implement is different from their specification, then: https://github.com/npm/node-semver/blob/master/classes/range.js#L91 - but it looks like I can pre-process the range with the same regex node-semver uses internally. |
So, just in case this comes useful for someone in the future, the npm logic translated to Python is as following: comparator_trim_re = re.compile(r'(\s*)((?:<|>)?=?)\s*([v=\s]*([0-9]+)\.([0-9]+)\.([0-9]+)(?:-?((?:[0-9]+|\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\.(?:[0-9]+|\d*[a-zA-Z-][a-zA-Z0-9-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?|[v=\s]*(0|[1-9]\d*|x|X|\*)(?:\.(0|[1-9]\d*|x|X|\*)(?:\.(0|[1-9]\d*|x|X|\*)(?:(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][a-zA-Z0-9-]*))*)))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?)?)?)')
def clean_up_npm_range(range):
return comparator_trim_re.sub(r'\1\2\3', range) |
I'm getting an error when parsing an expression from npmjs.com:
The full version spec was:
I did not make up this spec string - it was found when parsing package.json found on npm.
The text was updated successfully, but these errors were encountered: