fix: map block key management issue causing request failures due to invisible characters (#6521)

This commit is contained in:
Katherine 2025-03-21 13:17:00 +08:00 committed by GitHub
parent 2e737f74fd
commit 1470ed902a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -32,11 +32,19 @@ const BaseConfiguration: React.FC<BaseConfigurationProps> = ({ type, children })
return apiClient.resource(MapConfigurationResourceKey);
}, [apiClient]);
function removeInvisibleCharsFromObject(obj: Record<string, string>): Record<string, string> {
const cleanObj: Record<string, string> = {};
for (const [key, value] of Object.entries(obj)) {
cleanObj[key] = typeof value === 'string' ? value.replace(/[\p{C}\p{Z}\p{Zl}\p{Zp}]+/gu, '') : value;
}
return cleanObj;
}
const onSubmit = async (values) => {
await form.validateFields();
resource
.set({
...values,
...removeInvisibleCharsFromObject(values),
type,
})
.then((res) => {