OlegIlyenko / graphiql-workspace

A graphical interactive in-browser GraphQL IDE enhanced with tabbed navigation, HTTP headers, arbitrary endpoints, etc.

Home Page:http://toolbox.sangria-graphql.org/graphiql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Relax URL validation rules

kaqqao opened this issue · comments

Many valid URLs are rejected, e.g.:

Seems like the validation requires a dot and 2-4 letters following it.
Local testing sounds like a common use-case to me, so I'd suggest relaxing the validation rules to permit any well-formed URL.

Thanks for the report! A typical example of StackOverflow Driven Development on my side :)

https://github.com/OlegIlyenko/graphiql-workspace/blob/master/src/GraphiQLTab.jsx#L381-L382

Would you mind making PR improving this regexp?

This should be fixed with #22 as I had to reword the url validation.

Honestly, apart from checking that it starts with a protocol, there's no reasonable way to validate URLs. Unicode characters are now allowed (IDNA), IP v4 and v6 should be allowed, all sorts of aliases too, and there's pretty much no way to check for this. Even browsers don't bother to.

But, more importantly, why would the URL be validated (beyond the protocol) in the first place? One can still input a well formed but wrong URL, so validation can only restrict valid input and be obtrusive at worst and useless at best.

That's a fair argument but I am just giving an hand, @OlegIlyenko ultimately will decide if he wants to remove that or not, it's not my call to make.

Sure, didn't mean to criticize your approach, just to leave some thoughts for whoever ends up closing the issue... I was going to make a PR myself, but didn't know what to do for the same reason...
Thanks for the nice work!

Can this be now closed?

@kachkaev
Yup, seems to be working fine now. Although I'd still argue the URL validation part is best removed. My logic is explained in the post above.