Skip to content

fix: add check to see that all dot notated areas are numbers. #357

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

Merged
merged 1 commit into from
Aug 25, 2020

Conversation

thomaszurkan-optimizely
Copy link
Contributor

Summary

  • Add a check to make sure that the dot notated prefix is a number.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coveralls
Copy link

coveralls commented Aug 25, 2020

Coverage Status

Coverage remained the same at 98.841% when pulling 61d2b97 on fixInvalidSemver into 0919abe on master.

@msohailhussain msohailhussain self-requested a review August 25, 2020 17:33
@@ -88,7 +88,7 @@ extension SemanticVersion {
throw OptimizelyError.attributeFormatInvalid
}
var targetedVersionParts = targetPrefix.split(separator: ".")
guard targetedVersionParts.count == dotCount + 1 else {
guard targetedVersionParts.count == dotCount + 1 && targetedVersionParts.filter({$0.isNumber}).count == targetedVersionParts.count else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am just curious if we need condition written above.
else if !versionParts[idx].isNumber {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

during the evaluation after the suffix has been added it is correct to test if the version is not a number. i thought about adding the if versionParts is not a number and target is a number. But, it should really fail in the split as a invalid format.

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

Successfully merging this pull request may close these issues.

4 participants