fix: SDA-2882 - Validate notification background color (#1174)

This commit is contained in:
Kiran Niranjan 2021-01-20 14:39:30 +05:30 committed by GitHub
parent eaf1335359
commit 1baf0834c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -378,6 +378,8 @@ export default class NotificationComp extends React.Component<{}, IState> {
data.isInputHidden = true;
data.containerHeight = CONTAINER_HEIGHT;
data.color = this.isValidColor(data.color) ? data.color : '';
this.resetNotificationData();
this.setState(data as IState);
@ -397,6 +399,15 @@ export default class NotificationComp extends React.Component<{}, IState> {
}
}
/**
* Validates the color
* @param color
* @private
*/
private isValidColor(color: string): boolean {
return /^#([A-Fa-f0-9]{6})/.test(color);
}
/**
* Reset data for new notification
* @private