File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ class HTTP
22 attr_accessor :url
33
44 # TODO need better regexp
5- URL_REGEXP = /^(( http[s]?): \/ )? \/ ?([^: \/ \s ]+)(( \/ \w +)* \/ ) ([\w \ -\. ]+[^#? \s ]+)(.*)?(#[ \w \- ]+ )?$/
5+ URL_REGEXP = /^(http: \\ .|https: \\ .|http: \/ \/ |https: \/ \/ )?[a-z0-9]+ ([\- \. ]{1}[a-z0-9 ]+)* \. [a-z]{2,5}(:[0-9]{1,5})?( \/ .* )?$/
66 HOST_REGEXP = /^(?:https?:\/ \/ )?(?:[^@\/ \n ]+@)?(?:www\. )?([^:\/ \n ]+)/
77
88 HTTP_VERSION = 'HTTP/1.1'
@@ -14,6 +14,7 @@ class HTTP
1414 port : 80 ,
1515 ssl_port : 443 ,
1616 accept : '*/*' ,
17+ path : '/'
1718 }
1819
1920 ##
@@ -249,7 +250,7 @@ def parse_url(url, port)
249250 @url [ :ssl_enabled ] = !!url [ /^(https)/ ]
250251
251252 @url [ :host ] = url [ HOST_REGEXP ] . split ( url [ /^(http[s]?)/ ] + '://' ) [ 1 ]
252- @url [ :path ] = url . split ( url [ HOST_REGEXP ] ) [ 1 ]
253+ @url [ :path ] = url . split ( url [ HOST_REGEXP ] ) [ 1 ] || DEFAULTS [ :path ]
253254 else
254255 raise ArgumentError
255256 end
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def run_with_catching_error(&b)
1616end
1717
1818assert ( "make a request" ) do
19- http = HTTP . new ( "http://mruby.org/about/ " )
19+ http = HTTP . new ( "http://mruby.org" )
2020 response = http . request ( "GET" )
2121
2222 assert_equal response . nil? , false
You can’t perform that action at this time.
0 commit comments