fix(duration): handle multi-digit values in string formatting#321
Conversation
Fix the Duration.String() method to correctly handle zero-valued units in multi-digit time values. Previously, the code would incorrectly strip '0m' from values like '30m' or '0s' from '30s', treating the '0' as a standalone zero component when it was actually part of a larger number. The fix adds a helper function to check if a character is a digit and updates the stripping logic to only remove zero units when they are truly standalone (preceded by a unit letter or at the start of the string, not by another digit). Adds test cases for 10s, 30s, 60s, 90s, and 2h to ensure correct formatting of multi-digit values.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
WalkthroughThis PR tightens the zero-unit stripping logic in ChangesDuration zero-unit stripping precision
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Gavel summary
Totals: 406 passed · 1 failed · 4 skipped · 17.3s Failing lintersgolangci-lint — error |
|
🎉 This PR is included in version 1.53.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
What
Why
Changes
Summary by CodeRabbit