Server IP : 162.213.251.212 / Your IP : 3.145.178.65 [ Web Server : LiteSpeed System : Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : allssztx ( 535) PHP Version : 8.1.31 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/allssztx/clarkesmusicservices.com/node_modules/mpath/test/ |
Upload File : |
'use strict'; const assert = require('assert'); const stringToParts = require('../lib/stringToParts'); describe('stringToParts', function() { it('handles brackets for numbers', function() { assert.deepEqual(stringToParts('list[0].name'), ['list', '0', 'name']); assert.deepEqual(stringToParts('list[0][1].name'), ['list', '0', '1', 'name']); }); it('handles dot notation', function() { assert.deepEqual(stringToParts('a.b.c'), ['a', 'b', 'c']); assert.deepEqual(stringToParts('a..b.d'), ['a', '', 'b', 'd']); }); it('ignores invalid numbers in square brackets', function() { assert.deepEqual(stringToParts('foo[1mystring]'), ['foo[1mystring]']); assert.deepEqual(stringToParts('foo[1mystring].bar[1]'), ['foo[1mystring]', 'bar', '1']); assert.deepEqual(stringToParts('foo[1mystring][2]'), ['foo[1mystring]', '2']); }); it('handles empty string', function() { assert.deepEqual(stringToParts(''), ['']); }); it('handles trailing dot', function() { assert.deepEqual(stringToParts('a.b.'), ['a', 'b', '']); }); });