dekkerglen / CubeCobra

An open source web application for building, managing, and playtesting Magic the Gathering cubes.
https://www.cubecobra.com
Apache License 2.0
193 stars 120 forks source link

bug(csv) always convert header names from csv to camelCase #2464

Closed dvndrsn closed 1 month ago

dvndrsn commented 1 month ago

fixes #2458

There was a bug that prevented loading 'Color Category' column from properly loading from a CSV import. There was a hard-to-grok one liner that transformed parsed CSV headers from matching the header values exactly to lower cased values that still contained spaces. ex. 'Set' becomes 'set', 'Collector Number' becomes 'collector number', etc.

Then an object unpacking renamed the keys with spaces to camelCase. This rename is case sensitve still, so the line trying to rename the key 'Color Category' to 'colorCategory' would fail silently (the value would be undefined).

To fix the bug and make the transformation more clear, we now transform the header keys from 'Words With Spaces' to 'camelCaseWords' in one step. This is extracted into a named helper method for further clarity.