mathiasbynens / mathiasbynens/jsesc
Don’t replace `\x08` with `\b` in regular expressions
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 800
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
In regular expressions, \b has a different meaning than in strings (where it’s equivalent to '\x08'`):
/\b/.test('\b'); // false
/\x08/.test('\b'); // true
But jsesc incorrectly replaces \x08 in regular expressions with \b:
jsesc(/\x08/); // '/\\b/'
Only these single character escapes have the same meaning in regular expressions as in strings:
\f \n \r \t \v \0
Also see #11: \B, \w, \W, \s, \S, \d, \D, \cM, etc. should be preserved.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the documented jsesc(/\x08/) result and locate the regular-expression escaping path responsible for converting \x08 to \b. Preserve the distinct regular-expression meaning of \x08, then verify the example and related escape cases mentioned in the issue, including those in #11.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100