Repository navigation
fix: match hsb color strings case-insensitively - #309
mokshupadhyay wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
ChangesHSB 字符串大小写处理
Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix Suggested reviewers: Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #309 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 14 14
Lines 368 368
Branches 94 94
=========================================
Hits 368 368 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hi @yoyo837, a friendly ping: this is ready for review whenever you have time. Happy to adjust anything. Thanks! |
Coloracceptshsb(...)/hsba(...)strings by renaming the prefix tohsvbefore handing them to the color parser, but the check and the replacement are case-sensitive (/hsb/). CSS color function names are case-insensitive, and the parser treatsHSV(...)the same ashsv(...), soHSB(...)orHsBa(...)was not recognised and the color silently came out black instead of being parsed.Result of the new test (I measured the first row on the original source; the second row's "before" follows from the same code path and I did not measure it separately):
new Color('HSB(120, 100%, 100%)').toHexString()#000000(black)#00ff00new Color('HsBa(240, 100%, 100%, 0.5)').toRgbString()rgba(0,0,255,0.5)new Color('hsb(120, 100%, 100%)')#00ff00#00ff00The fix makes both regular expressions case-insensitive (
/hsb/i).Tests: added
should parse case-insensitive hsb and hsba strings; it fails on the original source and passes now.npm testpasses (3 files, 73 tests),npm run tscis clean andnpm run lintreports 0 errors (1 warning).Summary by CodeRabbit