Alexander Borisov
July 02, 2019 11:16AM
details: https://hg.nginx.org/njs/rev/0f2d18a5eed3
branches:
changeset: 1025:0f2d18a5eed3
user: Alexander Borisov <alexander.borisov@nginx.com>
date: Tue Jul 02 18:14:47 2019 +0300
description:
Fixed String.prototype.replace() for '$0' replacement string.

For example:
'0'.replace(/^/g, "$0")

diffstat:

njs/njs_string.c | 2 +-
njs/test/njs_unit_test.c | 3 +++
2 files changed, 4 insertions(+), 1 deletions(-)

diffs (25 lines):

diff -r 4a0f6ff54f88 -r 0f2d18a5eed3 njs/njs_string.c
--- a/njs/njs_string.c Mon Jul 01 22:44:14 2019 +0300
+++ b/njs/njs_string.c Tue Jul 02 18:14:47 2019 +0300
@@ -3470,7 +3470,7 @@ skip:

size = 2;

- if (c >= '0' && c <= '9') {
+ if (c >= '1' && c <= '9') {
type = c - '0';

if (p < end) {
diff -r 4a0f6ff54f88 -r 0f2d18a5eed3 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Mon Jul 01 22:44:14 2019 +0300
+++ b/njs/test/njs_unit_test.c Tue Jul 02 18:14:47 2019 +0300
@@ -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("/\\]/") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed String.prototype.replace() for '$0' replacement string.

Alexander Borisov 353 July 02, 2019 11:16AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 162
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready