Bug or at least unexpected side effect of replaceAll
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- tooling
Research direction
Start by locating the PureScript strings implementation of replaceAll and its JavaScript replace entry point, then inspect how replacement strings are passed through. Verify the suggested escaping behavior with a regression case involving $' and other dollar-prefixed replacement text; done means replacement strings remain literal.
Written by the indexing model from the issue text.
Description
In Javascript, the replace function when the first parameter is a Regex, there are special character strings for replacements, e.g. $'.
The problem is that the PureScript replaceAll relies on the JavaScript replace using a Regex with the global flag.
This means that replacement strings are simple string replacements, but instead are interpreted.
Suggested fix:
export const replaceAll = p => r => s => s.replace(new RegExp(p.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"), "g"), r.replace(/\$/g, "$$$$")); // eslint-disable-line no-useless-escape
We're replacing the $ with $$ globally in the replacement string.
- Dominant language
- PureScript
- Stars
- 57
- Forks
- 76
- PR merge metrics
- No merged PRs in 30d
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.
More from purescript/purescript-strings
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
purescript/purescript-strings#171 · 3 comments · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
purescript/purescript-strings#170 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
purescript/purescript-strings#169 · 7 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
purescript/purescript-strings#167 · 4 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
purescript/purescript-strings#164 · 2 comments ·
All issues in purescript/purescript-strings
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
0xMiden/bridge-portal#132 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
newrelic-experimental/preflight#793 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
babalae/bettergi-scripts-list#3674 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
caddyserver/caddy#8046 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zilliztech/memsearch#759 ·