From 9525c3cd8696d2346259bb873765f85d86788eee Mon Sep 17 00:00:00 2001 From: Isaac Cambron Date: Wed, 2 Oct 2013 11:19:31 -0400 Subject: [PATCH] Allow non-formatting tokens to include newlines. Fixes #1151 --- moment.js | 2 +- test/moment/format.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/moment.js b/moment.js index 8957b5188..3209dd9bb 100644 --- a/moment.js +++ b/moment.js @@ -684,7 +684,7 @@ function removeFormattingTokens(input) { - if (input.match(/\[.*\]/)) { + if (input.match(/\[[\s\S]/)) { return input.replace(/^\[|\]$/g, ""); } return input.replace(/\\/g, ""); diff --git a/test/moment/format.js b/test/moment/format.js index bf1e32f91..512e821ab 100644 --- a/test/moment/format.js +++ b/test/moment/format.js @@ -10,7 +10,7 @@ exports.format = { }, "format escape brackets" : function (test) { - test.expect(9); + test.expect(10); moment.lang('en'); @@ -24,6 +24,7 @@ exports.format = { test.equal(b.format('[L] L'), 'L 02/14/2009', 'localized tokens with escaped localized tokens'); test.equal(b.format('[L LL LLL LLLL aLa]'), 'L LL LLL LLLL aLa', 'localized tokens with escaped localized tokens'); test.equal(b.format('[LLL] LLL'), 'LLL February 14 2009 3:25 PM', 'localized tokens with escaped localized tokens (recursion)'); + test.equal(b.format('YYYY[\n]DD[\n]'), '2009\n14\n', 'Newlines'); test.done(); }, -- 2.47.2