-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
</div> | ||
); | ||
} | ||
|
||
onChangeToken = (event, token) => { | ||
const validToken = /[a-zA-Z0-9]{4}-?[a-zA-Z0-9]{4}-?[a-zA-Z0-9]{4}-?[a-zA-Z0-9]{4}/.test(token); | ||
const validToken = /[a-zA-Z0-9]{4}(-)?[a-zA-Z0-9]{4}(-)?[a-zA-Z0-9]{4}(-)?[a-zA-Z0-9]{4}/.test(token); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified to this:
/([a-z0-9]{4}(-)?){4}/i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I can't reproduce why -?
-> (-)?
.
/([a-z0-9]{4}-?){4}/i.test('2M28-4gXT-X2qW-bAa') // false
/([a-z0-9]{4}-?){4}/i.test('2M28-4gXT-X2qW-bAaS') // true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trim
ming the input might be worth, as users often copy & paste adjacent spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can read and understand it as-is so the bug we introduced jumped out immediately. Since I can see no benefit in crunching apart from making me straining my brain & eyes, I'm not going to crush it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be at least /^[a-zA-Z0-9]{4}(-)?[a-zA-Z0-9]{4}(-)?[a-zA-Z0-9]{4}(-)?[a-zA-Z0-9]{4}$/
|
The whole approach of having optional |
The thing is that the token input but the user gets modified anyway via |
We added the optional -'s due to an issue logged. My point is that issue is invalid since if you copy from authcodes, you should expect things to not work as you expected. We never direct any users there neither do we direct them to copy from storage. The ^ & $ is valid though, updated. |
* Cleanups & tests for #3945 * Externalise icons as per PR comments
No description provided.