Skip to content

Commit 8a93049

Browse files
Bug regex changes in front-end to make it similar regex in back-end (#214)
* regex change to match those in backend
1 parent c6ec741 commit 8a93049

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/main/resources/static/js/subscription.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,9 +831,15 @@ jQuery(document).ready(function () {
831831
$('#subscriptionNameInput').addClass("is-invalid");
832832
error = true;
833833
}
834-
834+
835+
// When this regExp need to be changed then remember to change the one in the
836+
// back-end (invalidSubscriptionNameRegex in SubscriptionValidator.java), which do the same
837+
// invalid subscription name check. The two
838+
// regEx always need to be the same for ensuring the same check.
835839
// /(\W)/ Is a regex that matches anything that is not [A-Z,a-z,0-8] and _.
836-
var regExpression = /(\W)/g;
840+
var invalidSubscriptionNameRegex = "(\W)";
841+
var regExpressionFlag = "g";
842+
var regExpression = new RegExp(invalidSubscriptionNameRegex, regExpressionFlag);
837843
if ((regExpression.test(subscriptionName))) {
838844
var invalidLetters = subscriptionName.match(regExpression);
839845
$('#invalidSubscriptionName').text(
@@ -866,6 +872,10 @@ jQuery(document).ready(function () {
866872
var emails = notificationMeta.split(",");
867873
emails.forEach(function(email){
868874
email = email.trim();
875+
// When this regExp need to be changed then remember to change the one in the
876+
// back-end (validEmailRegExpression in SubscriptionValidator.java), which do the same
877+
// email validation check. The two
878+
// regEx always need to be the same for ensuring the same check.
869879
var validEmailRegExpression = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
870880
var isValidEmailAddress = validEmailRegExpression.test(email);
871881
if (!isValidEmailAddress) {

0 commit comments

Comments
 (0)