elm-community / elm-community/string-extra

invalid range error when using dasherize()

Open
#46 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elm
Stars
36
Forks
27
PR merge metrics
No merged PRs in 30d

Description

While testing an application built with Elm, I came across an error triggered by using the dasherize() method. It seems that the RegEx `[_-\\s]+` used in the method is not a legitimate expression in many languages and javascript parsers written in those languages throw an exception when executing this code because the `-` is seen as part of an invalid range terminated by a character group.

I'm not sure of all of the use cases, but ECMAScript seems to interpret the expression as a range without an end. But it also seems that the desired behavior (as I see it) could also be achieved using the RegEx
`[_\\s-]+` or even
`[_\-\\s]+"` so that the "-" is not interpreted as a range. But it might be the case that an open ended range is required for some cases, though a range that begins with "_" seems like it would match nearly everything.

I'm not certain, so opening an issue.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.