Is there an empty URI?

房东的猫 提交于 2019-12-24 00:53:00

问题


I working on a routine that parses a URI. Among obvious cases there is an empty string case. Is the empty string a valid input? What would be an outcome URI of an empty string?


回答1:


An empty string can’t possibly be a URI. The general URI syntax specifies that at least the scheme component followed by a : followed by the hier-part component (which may be empty) must be present.

But a relative URI reference can be empty. The syntax of relative references specifies that at least the relative-part component must be present, but it’s allowed to be empty (path-empty).

An empty relative URI reference is a same-document reference (bold emphasis mine):

The most frequent examples of same-document references are relative references that are empty or include only the number sign ("#") separator followed by a fragment identifier.




回答2:


Since the root of a URI is a limited set we know it does not have a valid root. It therefore does not identify anything and is invalid as an identifier. But this might have a meaning in your context still since tere is no specific standard for a URI.



来源:https://stackoverflow.com/questions/43333664/is-there-an-empty-uri

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!