Which characters make a URL invalid?

后端 未结 10 1236
小蘑菇
小蘑菇 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:49

    In your supplementary question you asked if www.example.com/file[/].html is a valid URL.

    That URL isn't valid because a URL is a type of URI and a valid URI must have a scheme like http: (see RFC 3986).

    If you meant to ask if http://www.example.com/file[/].html is a valid URL then the answer is still no because the square bracket characters aren't valid there.

    The square bracket characters are reserved for URLs in this format: http://[2001:db8:85a3::8a2e:370:7334]/foo/bar (i.e. an IPv6 literal instead of a host name)

    It's worth reading RFC 3986 carefully if you want to understand the issue fully.

提交回复
热议问题