Skip to content

Make `convertToSnakeCase` gracefully handle edge cases

Nathan Friend requested to merge nfriend-fix-convert-to-snake-case into master

What does this MR do?

Updates the convertToSnakeCase utility function to gracefully handle edge cases. In particular, the function would previously throw an error if a string containing only digits was passed (e.g. "123").

Previously, the function would fail if the regex it used internally failed to match the input string.

Now, if the regex doesn't match the input string, it will simply return the slugify'd version of the input string instead of throwing an error.

Context

Discovered while putting together !33437 (merged).

Edited by Nathan Friend

Merge request reports