Add AWS region validation and improve code style.

This commit is contained in:
glay 2024-11-13 08:08:01 +08:00 committed by GitHub
parent bfa433919f
commit 70f066c15f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
})
}
/>
</ListItem>