Welcome! Log In Create A New Profile

Advanced

[njs] Array.indexOf() and Array.lastIndexOf() have been fixed.

October 18, 2016 11:06AM
details: http://hg.nginx.org/njs/rev/fa9ced8246e5
branches:
changeset: 208:fa9ced8246e5
user: Igor Sysoev <igor@sysoev.ru>
date: Tue Oct 18 17:44:01 2016 +0300
description:
Array.indexOf() and Array.lastIndexOf() have been fixed.

diffstat:

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

diffs (25 lines):

diff -r 59b3b4a0b535 -r fa9ced8246e5 njs/njs_array.c
--- a/njs/njs_array.c Tue Oct 18 15:48:22 2016 +0300
+++ b/njs/njs_array.c Tue Oct 18 17:44:01 2016 +0300
@@ -996,7 +996,7 @@ njs_array_index_of(njs_vm_t *vm, njs_val

index = -1;

- if (nargs > 1) {
+ if (nargs > 1 && njs_is_array(&args[0])) {
i = 0;
array = args[0].data.u.array;
length = array->length;
diff -r 59b3b4a0b535 -r fa9ced8246e5 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Tue Oct 18 15:48:22 2016 +0300
+++ b/njs/test/njs_unit_test.c Tue Oct 18 17:44:01 2016 +0300
@@ -2359,6 +2359,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("var a = [1,2,3,4,3,4]; a.indexOf(3, -10)"),
nxt_string("2") },

+ { nxt_string("[].indexOf.bind(0)(0, 0)"),
+ nxt_string("-1") },
+
{ nxt_string("var a = [1,2,3,4]; a.lastIndexOf()"),
nxt_string("-1") },


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

[njs] Array.indexOf() and Array.lastIndexOf() have been fixed.

Igor Sysoev 769 October 18, 2016 11:06AM



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

Online Users

Guests: 335
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready