Validation for Trailing Space in URL

3 replies
Last updated: Apr 16, 2021
The URL schema type seems to allow trailing spaces, is this expected behavior, and if so, is there a preferred way to augment it accordingly?
Apr 16, 2021, 4:34 PM
I found this so it’s a good start, but url parsing seems to just ignore whitespace.. need to trim that automatically somehow?
Apr 16, 2021, 4:44 PM
Alright I got it with a very strict regex, and it catches this trailing space. Oddly, the input field doesn’t render it, so you don’t see it and can’t even “delete” it. So, you just need to modify the field (maybe delete and re-add the last character which saves the field without a space) and then it works. Kinda janky but suspect it’s something to do with html not rendering whitespace?
Apr 16, 2021, 4:57 PM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?

Categorized in