valibot
valibot copied to clipboard
Support for relative URLs
As the current url() validation action relies on the URL constructor, which requires a base argument when the URL is relative, relative URLs are not considered to be valid URLs by the current implementation. There are cases where a relative URL is useful as a valid input, but users would need to write their own custom relative URL validation action to validate this at the moment. It would be nice if Valibot can support this by default.
Hey 👋 thank you for reaching out! Can you give an example for a relative URL? I just want to make sure we are not mixing it with relative paths. If you are looking for a relative path you could probably use regex or we can think about adding support for a new path action.
I was mostly only thinking about URLs like /a/b/c because that was what my project needed support for, but for completeness, I would look towards WHATWG's URL standard. Mozilla's documentation seems to cover that at first glance, but I haven't looked too deeply into the spec myself.
Thank you for the context and links. For now, I would recommend using regex as a workaround. I will wait for more users before taking an action on this regard.