diff --git a/index.js b/index.js
index 2920a31..faf53ef 100644
--- a/index.js
+++ b/index.js
@@ -62,7 +62,15 @@ const match = (payload, pattern, callback) => {
*/
} else if (element instanceof Object) {
currentNode[key][index] = {}
- tester(payload[key][index], element, currentNode[key][index])
+
+ payload[key].forEach((payloadItem, payloadIndex) => {
+ if (payloadItem instanceof Object) {
+ const payloadItemMatch = match(payloadItem, element)
+ if (payloadItemMatch.match) {
+ tester(payload[key][payloadIndex], element, currentNode[key][index])
+ }
+ }
+ })
} else if (payload[key].includes(element)) {
currentNode[key][index] = element
result.total += 1
diff --git a/package.json b/package.json
index f7d9a87..bc55736 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@menadevs/objectron",
- "version": "0.1.12",
+ "version": "0.1.13",
"description": "Compares a set of match rules contained with an object to determine if the latter conforms to the matching rules",
"main": "index.js",
"devDependencies": {
diff --git a/test/test_objectron.js b/test/test_objectron.js
index 9de41ee..77ec5c8 100644
--- a/test/test_objectron.js
+++ b/test/test_objectron.js
@@ -564,7 +564,15 @@ suite('Objectron Core Tests', () => {
{
type: 'markdown',
text: '*This must be it*'
- }
+ },
+ {
+ type: 'html',
+ text: 'Hello world'
+ },
+ {
+ type: 'yaml',
+ text: 'Another text!'
+ },
]
}
}
@@ -578,14 +586,22 @@ suite('Objectron Core Tests', () => {
{
type: 'markdown',
text: /.*/
- }
+ },
+ {
+ type: 'html',
+ text: /(.*?)<\/b>/
+ },
+ {
+ type: 'yaml',
+ text: /(?.*)/,
+ },
]
}
})
const expected = {
match: true,
- total: 8,
+ total: 11,
matches: {
api: 13,
ids: [12, 130, 45],
@@ -595,13 +611,24 @@ suite('Objectron Core Tests', () => {
{
type: 'markdown',
text: '*This must be it*'
- }
+ },
+ {
+ type: 'html',
+ text: 'Hello world'
+ },
+ {
+ type: 'yaml',
+ text: 'Another text!'
+ },
]
}
},
- groups: {}
+ groups: {
+ yamlText: 'Another text!'
+ }
}
- assert.isFalse(result.match)
+ assert.isTrue(result.match)
+ assert.deepEqual(result, expected)
})
})