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
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
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
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
jeanibarz/knowledge-base-mcp-server#1268 ·
Maintainers usually reply within 1 day
-
trace: Pi's 1-hour cache writes are priced at 1.25x, but billed at 2xPossibly taken @Shizoqua claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/TokenEconomizer#221 ·
Maintainers usually reply within 1 day
-
transformer-directives: `@apply` drops a utility whose CSS is a substring of an earlier one'sPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
compiler bench: virtual.bench.ts "every id resolved and loaded" throws virtual_wrong_realm on mainOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100