String and text fields coming back with over 100 invisible characters #5782
Replies: 3 comments 1 reply
-
@BennyHinrichs Unfortunately cannot help but just wanted to bump this to say we are also getting some invisible characters in our strings which is breaking out frontend 🤔.
When I get this value on the frontend, it looks harmless, but |
Beta Was this translation helpful? Give feedback.
-
This is the sanitization function I ended up creating export function sanitize(data: Record<string, any>) {
Object.keys(data).forEach((key) => {
if (typeof data[key] === 'string') {
data[key] = data[key].replace(/(\u200b|\u200c|\u200d|\ufeff)/g, '');
} else if (typeof data[key] === 'object') {
sanitize(data[key]);
}
});
} |
Beta Was this translation helpful? Give feedback.
-
I just encountered the same issue for the following definition
|
Beta Was this translation helpful? Give feedback.
-
I cloned this repo yesterday https://github.com/sanity-io/sanity-template-remix-clean. Got some documents set up and querying in the client app. The response on the client for
string
andtext
fields includes an insane amount of non-visible characters likezero-width space
andzero-width non-joiner
. Copy the below example and paste it in your console to see.Other fields that are ostensibly strings but nominally have a different type (e.g.
url
) do not have the junk string appended to them.So if I have a field like
It's more or less useless because when I consume it like
It just has a ton of garbage on the end. And sure, I can write a sanitizer function. But I feel like I shouldn't have to sanitize Sanity in a self-contained app. Anyone know why all the invisible characters are getting tagged on my strings?
Beta Was this translation helpful? Give feedback.
All reactions