Skip to content

fix: handle version suffix like 'p1', 'a', 'b' in compare()#7

Open
contem wants to merge 1 commit intoleohihimax:masterfrom
contem:fix/handle-version-suffix
Open

fix: handle version suffix like 'p1', 'a', 'b' in compare()#7
contem wants to merge 1 commit intoleohihimax:masterfrom
contem:fix/handle-version-suffix

Conversation

@contem
Copy link

@contem contem commented Apr 20, 2025

This PR improves the compare() function to correctly handle version strings that include suffixes such as 8.5p1, 10.2a, etc. These suffixes are commonly used in systems like OpenSSH.

Before:

compare('8.5', '8.5p1'); // returned 0 (incorrect)

After:

compare('8.5', '8.5p1'); // now returns -1 (correct)

Changes:

  • Enhanced split() to detect and separate numeric-alphabetic suffixes.
  • Improved convertToNumber() to preserve alphas properly.
  • Added sample test cases to test.js (optional).

Let me know if any changes are needed!

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.

1 participant

Comments