Which characters make a URL invalid?

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

    In general URIs as defined by RFC 3986 (see Section 2: Characters) may contain any of the following 84 characters:

    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=
    

    Note that this list doesn't state where in the URI these characters may occur.

    Any other character needs to be encoded with the percent-encoding (%hh). Each part of the URI has further restrictions about what characters need to be represented by an percent-encoded word.

提交回复
热议问题