From 632b007c0de38c21b57154035d6f2a1f9d923ff7 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Mon, 23 May 2022 12:22:14 +0200 Subject: [PATCH] SONAR-16227 Fix token format validation during tutorial --- .../src/main/js/components/tutorials/manual/TokenStep.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/TokenStep.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/TokenStep.tsx index b3ab6871a82..495e3c3b1a0 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/TokenStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/TokenStep.tsx @@ -51,6 +51,8 @@ interface State { tokens?: UserToken[]; } +const TOKEN_FORMAT_REGEX = /^[_a-z0-9]+$/; + export default class TokenStep extends React.PureComponent { mounted = false; @@ -91,7 +93,7 @@ export default class TokenStep extends React.PureComponent { canContinue = () => { const { existingToken, selection, token } = this.state; - const validExistingToken = existingToken.match(/^[a-z0-9]+$/) != null; + const validExistingToken = existingToken.match(TOKEN_FORMAT_REGEX) != null; return ( (selection === 'generate' && token != null) || (selection === 'use-existing' && existingToken && validExistingToken) @@ -206,7 +208,7 @@ export default class TokenStep extends React.PureComponent { renderUseExistingOption = () => { const { existingToken } = this.state; - const validInput = !existingToken || existingToken.match(/^[a-z0-9]+$/) != null; + const validInput = !existingToken || existingToken.match(TOKEN_FORMAT_REGEX) != null; return (
-- 2.39.5