From: Alexander Borisov Date: Tue, 2 Jul 2019 15:14:47 +0000 (+0300) Subject: Fixed String.prototype.replace() for '$0' replacement string. X-Git-Tag: 0.3.4~102 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=1d842ceccf86bbeef6beadc1efb8287c4a4518fe;p=njs.git Fixed String.prototype.replace() for '$0' replacement string. For example: '0'.replace(/^/g, "$0") --- diff --git a/njs/njs_string.c b/njs/njs_string.c index ba4358c8..fa60e85c 100644 --- a/njs/njs_string.c +++ b/njs/njs_string.c @@ -3470,7 +3470,7 @@ skip: size = 2; - if (c >= '0' && c <= '9') { + if (c >= '1' && c <= '9') { type = c - '0'; if (p < end) { diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 81db47df..24ecf857 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -5566,6 +5566,9 @@ static njs_unit_test_t njs_test[] = { nxt_string("'abc'.replace(/(a*)/g, function v0() {return '124'})"), nxt_string("124124b124c124") }, + { nxt_string("typeof '0'.replace(/^/g, '$0')"), + nxt_string("string") }, + { nxt_string("/]/"), nxt_string("/\\]/") },