diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /app/assets/javascripts/profile/add_ssh_key_validation.js | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'app/assets/javascripts/profile/add_ssh_key_validation.js')
-rw-r--r-- | app/assets/javascripts/profile/add_ssh_key_validation.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/app/assets/javascripts/profile/add_ssh_key_validation.js b/app/assets/javascripts/profile/add_ssh_key_validation.js index 5c78de7ffb0..628dd159db8 100644 --- a/app/assets/javascripts/profile/add_ssh_key_validation.js +++ b/app/assets/javascripts/profile/add_ssh_key_validation.js @@ -1,8 +1,17 @@ export default class AddSshKeyValidation { - constructor(inputElement, warningElement, originalSubmitElement, confirmSubmitElement) { + constructor( + supportedAlgorithms, + inputElement, + warningElement, + originalSubmitElement, + confirmSubmitElement, + ) { this.inputElement = inputElement; this.form = inputElement.form; + this.supportedAlgorithms = supportedAlgorithms; + this.publicKeyRegExp = new RegExp(`^(${this.supportedAlgorithms.join('|')})`); + this.warningElement = warningElement; this.originalSubmitElement = originalSubmitElement; @@ -23,7 +32,7 @@ export default class AddSshKeyValidation { } submit(event) { - this.isValid = AddSshKeyValidation.isPublicKey(this.inputElement.value); + this.isValid = this.isPublicKey(this.inputElement.value); if (this.isValid) return true; @@ -37,7 +46,7 @@ export default class AddSshKeyValidation { this.originalSubmitElement.classList.toggle('hide', isVisible); } - static isPublicKey(value) { - return /^(ssh|ecdsa-sha2)-/.test(value); + isPublicKey(value) { + return this.publicKeyRegExp.test(value); } } |