WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
200714
String.prototype.replace truncates $<number> values
https://bugs.webkit.org/show_bug.cgi?id=200714
Summary
String.prototype.replace truncates $<number> values
matt
Reported
2019-08-14 07:36:27 PDT
# Summary When replacing with a value that contains $<number>, the value is truncated of $ and first number. # Test var string = "Get %{amount} credit"; var regex = new RegExp(`%{amount}`, "g"); console.log(string.replace(regex, "$100")); # Expected
> Get $100 credit
# Actual
> Get 00 credit
Attachments
Add attachment
proposed patch, testcase, etc.
matt
Comment 1
2019-08-14 07:39:08 PDT
This could be related to a non-standard feature:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n#Examples
Radar WebKit Bug Importer
Comment 2
2019-08-14 09:59:13 PDT
<
rdar://problem/54306164
>
matt
Comment 3
2019-08-19 01:18:27 PDT
After further investigation, this issue looks to be caused by an old String.prototype.replace polyfill from
core-js@2.0.3
. Ref:
https://github.com/zloirock/core-js/blob/v2.0.3/modules/es6.regexp.replace.js
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug