Skip to content
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

Prevent Inverted SemVersionRange Values ("1.2 - 1.0") #77

Closed
damepatr opened this issue Jan 19, 2023 · 2 comments
Closed

Prevent Inverted SemVersionRange Values ("1.2 - 1.0") #77

damepatr opened this issue Jan 19, 2023 · 2 comments

Comments

@damepatr
Copy link

The SemVersionRange.TryParseNpm methods will return true if you pass inverted version ranges.

Example

Imagine that you are trying to check if a version range is a valid version range. You can create code similar to the following:

public static bool IsValidRange(string range) {
    return SemVersionRange.TryParseNpm(range, out _);
}

When passing 1.2 - 1.0 for range, this method returns true. However, I thought that it would return false. I think that 1.2 - 1.0 isn't a valid version range for NPM.

@WalkerCodeRanger
Copy link
Owner

I believe 1.2 - 1.0 is a valid but empty range according to npm. You can see this easily using https://semver.npmjs.com/

I understand why it feels like it might be invalid, but according to the official npm, which TryParseNpm is trying to match, it is.

@damepatr
Copy link
Author

I believe 1.2 - 1.0 is a valid but empty range according to npm. You can see this easily using https://semver.npmjs.com/

I understand why it feels like it might be invalid, but according to the official npm, which TryParseNpm is trying to match, it is.

@WalkerCodeRanger - Apologies for reporting something that isn't an issue. Thanks for looking into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants