Parsing URIs that have curly braces, URI::InvalidURIError: bad URI(is not URI?)

后端 未结 2 1759
小蘑菇
小蘑菇 2021-01-14 06:39

Using ruby 1.9.2-p290. I came across an issue trying to parse a URI like the following:

require \'uri\'
my_uri = \"http://www.anyserver.com/getdata?anyparame         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-14 07:37

    RFC 1738 - http://www.faqs.org/rfcs/rfc1738.html means that you do have to encode the braces

    Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
    reserved characters used for their reserved purposes may be used
    unencoded within a URL.
    

提交回复
热议问题