diff --git a/packages/bbob-html/lib/index.js b/packages/bbob-html/lib/index.js index 1113638..7af35a8 100644 --- a/packages/bbob-html/lib/index.js +++ b/packages/bbob-html/lib/index.js @@ -20,7 +20,7 @@ const renderNode = (node, { stripTags = false }) => { if (type === 'object') { if (stripTags === true) { // eslint-disable-next-line no-use-before-define - return renderNodes(node.content); + return renderNodes(node.content, { stripTags }); } if (node.content === null) { @@ -33,7 +33,7 @@ const renderNode = (node, { stripTags = false }) => { if (Array.isArray(node)) { // eslint-disable-next-line no-use-before-define - return renderNodes(node); + return renderNodes(node, { stripTags }); } return ''; diff --git a/packages/bbob-html/test/index.test.js b/packages/bbob-html/test/index.test.js index 4d85905..2b9987f 100644 --- a/packages/bbob-html/test/index.test.js +++ b/packages/bbob-html/test/index.test.js @@ -1,7 +1,7 @@ const render = require('../lib/index'); const parse = require('@bbob/parser'); -const process = input => render(parse(input)); +const process = (input, params) => render(parse(input), params); describe('@bbob/html', () => { test('render bbcode tag with single param as html tag', () => { @@ -24,4 +24,20 @@ describe('@bbob/html', () => { expect(process(input)).toBe(result); }); + + test('strip tags', () => { + const input = '[url]https://ru.wikipedia.org[/url]'; + const result = 'https://ru.wikipedia.org'; + + expect(process(input, { stripTags: true })).toBe(result); + }); + + test('array of nodes', () => { + const input = [ + 'https://ru.wikipedia.org' + ]; + const result = 'https://ru.wikipedia.org'; + + expect(render(input)).toBe(result); + }); });