Skip to content

Commit

Permalink
Fixed: Escape dash character (#11)
Browse files Browse the repository at this point in the history
An unescaped dash can be misinterpreted in JavaScript, so it is escaped.

This is a follow-on from elm-community/string-extra#47, but the method of fixing it is to explicitly escape the dash, rather than moving its position.
  • Loading branch information
ahankinson authored Sep 4, 2023
1 parent 51d5d04 commit 7fabb10
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/String/Extra.elm
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ underscored string =
string
|> String.trim
|> Regex.replace (regexFromString "([a-z\\d])([A-Z]+)") (.submatches >> List.filterMap identity >> String.join "_")
|> Regex.replace (regexFromString "[_-\\s]+") (always "_")
|> Regex.replace (regexFromString "[_\\-\\s]+") (always "_")
|> String.toLower


Expand Down

0 comments on commit 7fabb10

Please sign in to comment.