Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 81c32f9

Browse files
committed
fix(date filter): handle newlines in format string
Closes #15794
1 parent 1daa4f2 commit 81c32f9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/ng/filter/filters.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ var DATE_FORMATS = {
475475
GGGG: longEraGetter
476476
};
477477

478-
var DATE_FORMATS_SPLIT = /((?:[^yMLdHhmsaZEwG']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|m+|s+|a|Z|G+|w+))(.*)/,
478+
var DATE_FORMATS_SPLIT = /((?:[^yMLdHhmsaZEwG']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|m+|s+|a|Z|G+|w+))([\s\S]*)/,
479479
NUMBER_STRING = /^-?\d+$/;
480480

481481
/**

test/ng/filter/filtersSpec.js

+5
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,11 @@ describe('filters', function() {
504504
expect(date(morning, 'yy/xxx')).toEqual('10/xxx');
505505
});
506506

507+
it('should allow newlines in format', function() {
508+
expect(date(midnight, 'EEE\nMMM d\'\n\'yy/xxx\n')).
509+
toEqual('Fri\nSep 3\n10/xxx\n');
510+
});
511+
507512
it('should support various iso8061 date strings with timezone as input', function() {
508513
var format = 'yyyy-MM-dd ss';
509514

0 commit comments

Comments
 (0)