Skip to content

Inputted domain can be used directly in regex, causing an error #34

Open
@m50d

Description

@m50d

Current Behavior

https://github.com/ZooTools/email-spell-checker/blob/420dc73a72316848c2bd908c6fb95e4aa9aa0855/src/lib/suggest-email.ts#L90 constructs a regex by string manipulation, which causes an exception if we reach that line with a domain that contains invalid regex syntax.

Expected Behavior

Calling with any input should either suggest an email or fail cleanly (returning undefined), not throw an exception.

Steps to Reproduce the Problem

> const suggestedEmail4 = emailSpellChecker.run({
...   email: '[email protected])',
... })
Uncaught SyntaxError: Invalid regular expression: /co)$/: Unmatched ')'

Environment

  • Version: 1.12.0
  • Platform: Linux
  • Node.js Version: v18.19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions