valibot icon indicating copy to clipboard operation
valibot copied to clipboard

Support for relative URLs

Open benedictleejh opened this issue 4 months ago • 3 comments

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.

benedictleejh avatar Jul 21 '25 14:07 benedictleejh

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.

fabian-hiller avatar Jul 27 '25 02:07 fabian-hiller

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.

benedictleejh avatar Jul 27 '25 05:07 benedictleejh

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.

fabian-hiller avatar Jul 30 '25 02:07 fabian-hiller