Skip to content

@stdlib/string/base/constantcase doesn't change hyphens to underscores #1017

@romanstetsyk

Description

@romanstetsyk

Description

Encountered a bug in @stdlib/string/base/constantcase. If a string contains hyphens, '-', they are not changed to '_'. The issue is in this line of code. The regular expression doesn't contain a hyphen (U+002D), but it does contain an endash (U+2013).
Other similar packages for changing string cases contain both characters in the regular expression.

image

Related Issues

No response

Questions

No.

Demo

No response

Reproduction

`console.log(constantcase('foo-bar'))`

Expected Results

`'FOO_BAR'`

Actual Results

`'FOO-BAR'`

Version

v0.0.96

Environments

N/A

Browser Version

No response

Node.js / npm Version

No response

Platform

No response

Checklist

  • Read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions