Which characters make a URL invalid?

后端 未结 10 1232
小蘑菇
小蘑菇 2020-11-21 05:03

Which characters make a URL invalid?

Are these valid URLs?

  • example.com/file[/].html
  • http://example.com/file[/].html<
10条回答
  •  旧巷少年郎
    2020-11-21 05:42

    Not really an answer to your question but validating url's is really a serious p.i.t.a You're probably just better off validating the domainname and leave query part of the url be. That is my experience. You could also resort to pinging the url and seeing if it results in a valid response but that might be too much for such a simple task.

    Regular expressions to detect url's are abundant, google it :)

提交回复
热议问题