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

This regex is broken by design #14

Closed
jwdonahue opened this issue Jun 22, 2018 · 4 comments · Fixed by #15
Closed

This regex is broken by design #14

jwdonahue opened this issue Jun 22, 2018 · 4 comments · Fixed by #15
Labels
bug 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted

Comments

@jwdonahue
Copy link

jwdonahue commented Jun 22, 2018

Issuehunt badges

Test it against the following data set, it will pass some non-conforming strings and fail to pass some that are conforming.

1.2.3----RC-SNAPSHOT.12.9.1--.12
1.0.0+0.build.1-rc.10000aaa-kk-0.1
99999999999999999999999.999999999999999999.99999999999999999
Begin Invalid

1
1.2
1.2.3-0123
1.2.3-0123.0123
1.1.2+.123
+invalid
-invalid
-invalid+invalid
-invalid.01
alpha
alpha.beta
alpha.beta.1
alpha.1
alpha+beta
alpha_beta
alpha.
alpha..
beta
1.0.0-alpha_beta
-alpha.
1.0.0-alpha..
1.0.0-alpha..1
1.0.0-alpha...1
1.0.0-alpha....1
1.0.0-alpha.....1
1.0.0-alpha......1
1.0.0-alpha.......1
01.1.1
1.01.1
1.1.01
1.2
1.2.3.DEV
1.2-SNAPSHOT
1.2.31.2.3----RC-SNAPSHOT.12.09.1--..12+788
1.2-RC-SNAPSHOT
-1.0.3-gamma+b7718
+justmeta
9.8.7+meta+meta
9.8.7-whatever+meta+meta
99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12

See semver/semver/issues/59.

stroncium earned $70.00 by resolving this issue!

@sindresorhus sindresorhus changed the title This regex is broken by design. This regex is broken by design Mar 15, 2019
@IssueHuntBot
Copy link

@IssueHunt has funded $70.00 to this issue.


@ammarbinfaisal1
Copy link

I can't any fault with the regex itself other than it is giving true for some wrong versions because of \b present in the start and end (regex only matches the correct part but using .test() would return true https://regex101.com/r/sezmjS/2 ) Apparently it was used instead of ^ and $ so that people can use functions like match and exec. Using the same regex for test and other functions doesn't appear to be possible. I am sorry if I've failed to understand something. Do correct me if I have.

@jwdonahue
Copy link
Author

@ammarbinfaisal, just try testing it against the test data I posted. It can't possibly work because it does not properly take into account, all of the SemVer rules. It is one of many dozens of naive SemVer regex's.

stroncium added a commit to stroncium/semver-regex that referenced this issue Mar 24, 2019
@IssueHuntBot
Copy link

@sindresorhus has rewarded $63.00 to @stroncium. See it on IssueHunt

  • 💰 Total deposit: $70.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $7.00

@issuehunt-oss issuehunt-oss bot added the 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt label May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants