From 70f066c15f4e3d2baa9af15f34aa1557df7af356 Mon Sep 17 00:00:00 2001 From: glay Date: Wed, 13 Nov 2024 08:08:01 +0800 Subject: [PATCH] Add AWS region validation and improve code style. --- app/components/settings.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 8a942baf7..75672a140 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -978,9 +978,14 @@ export function Settings() { value={accessStore.awsRegion} placeholder="us-west-2" onChange={(e) => - accessStore.update( - (access) => (access.awsRegion = e.currentTarget.value), - ) + accessStore.update((access) => { + const region = e.currentTarget.value; + if (!/^[a-z]{2}-[a-z]+-\d+$/.test(region)) { + showToast(Locale.Settings.Access.Bedrock.Region.Invalid); + return; + } + access.awsRegion = region; + }) } />