From 79014c87bde3bdcf923519138e1b3a89ab73af28 Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Sat, 6 Jul 2024 23:45:38 -0500 Subject: [PATCH] Add test case for special regex characters --- test/test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test.js b/test/test.js index fc0a05c..73cfc54 100644 --- a/test/test.js +++ b/test/test.js @@ -78,4 +78,12 @@ describe('csvToMarkdown', function () { var result = csvToMarkdown('"foo";"bar";"baz"\n"1";"2";"[foo -;- bar baz]"', ";", true); assert.strictEqual(result, '| "foo" | "bar" | "baz" | \n|-------|-------|---------------------| \n| "1" | "2" | "[foo -;- bar baz]" | \n'); }); + + it('should handle delimiters that are regex special characters', function () { + var delimiters = ['[', ']', '\\', '/', '^', '$', '.', '|', '?', '*', '+', '(', ')', '{', '}', '-']; + delimiters.forEach(function (delimiter) { + var result = csvToMarkdown('a' + delimiter + 'b' + delimiter + 'c', delimiter, false); + assert.strictEqual(result, '| | | | \n|---|---|---| \n| a | b | c | \n', 'Failed for delimiter: "' + delimiter + '"'); + }); + }); });