Can a URL contain a semicolon and still be valid?

前端 未结 7 1498
故里飘歌
故里飘歌 2020-11-30 04:47

I am using a regular expression to convert plain text URL to clickable links.

@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.-]*(\\?\\S+)?)?)?)@

Ho

7条回答
  •  孤街浪徒
    2020-11-30 05:05

    A semicolon is reserved and should only for its special purpose (which depends on the scheme).

    Section 2.2:

    Many URL schemes reserve certain characters for a special meaning: their appearance in the scheme-specific part of the URL has a designated semantics. If the character corresponding to an octet is reserved in a scheme, the octet must be encoded. The characters ";", "/", "?", ":", "@", "=" and "&" are the characters which may be reserved for special meaning within a scheme. No other characters may be reserved within a scheme.

提交回复
热议问题