server id validation

pull/22091/head
JzoNg 11 months ago
parent 14a1bba9b7
commit 061eada8c5

@ -73,6 +73,10 @@ const MCPModal = ({
} }
} }
const isValidServerID = (str: string) => {
return /^[a-z0-9_-]{1,24}$/.test(str)
}
const handleBlur = async (url: string) => { const handleBlur = async (url: string) => {
if (data) if (data)
return return
@ -99,7 +103,7 @@ const MCPModal = ({
Toast.notify({ type: 'error', message: 'invalid server url' }) Toast.notify({ type: 'error', message: 'invalid server url' })
return return
} }
if (!serverIdentifier.trim()) { if (!isValidServerID(serverIdentifier.trim())) {
Toast.notify({ type: 'error', message: 'invalid server identifier' }) Toast.notify({ type: 'error', message: 'invalid server identifier' })
return return
} }

Loading…
Cancel
Save