Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(isRFC3339): Disallow prepended and appended strings to RFC 3339 date-time #1654

Merged
merged 1 commit into from Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/isRFC3339.js
Expand Up @@ -19,7 +19,7 @@ const partialTime = new RegExp(`${timeHour.source}:${timeMinute.source}:${timeSe
const fullDate = new RegExp(`${dateFullYear.source}-${dateMonth.source}-${dateMDay.source}`);
const fullTime = new RegExp(`${partialTime.source}${timeOffset.source}`);

const rfc3339 = new RegExp(`${fullDate.source}[ tT]${fullTime.source}`);
const rfc3339 = new RegExp(`^${fullDate.source}[ tT]${fullTime.source}$`);

export default function isRFC3339(str) {
assertString(str);
Expand Down
4 changes: 4 additions & 0 deletions test/validators.js
Expand Up @@ -8925,6 +8925,8 @@ describe('Validators', () => {
'2010-02-18T16:23.33.600',
'2010-02-18T16,25:23:48,444',
'2010-13-1',
'nonsense2021-01-01T00:00:00Z',
'2021-01-01T00:00:00Znonsense',
];

it('should validate ISO 8601 dates', () => {
Expand Down Expand Up @@ -9107,6 +9109,8 @@ describe('Validators', () => {
'2009-05-00 14:39:22+0600',
'2009-00-1 14:39:22Z',
'2009-05-19T14:39:22',
'nonsense2021-01-01T00:00:00Z',
'2021-01-01T00:00:00Znonsense',
],
});
});
Expand Down