File tree 2 files changed +4
-3
lines changed 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ class HTTP
2
2
attr_accessor :url
3
3
4
4
# 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})?( \/ .* )?$/
6
6
HOST_REGEXP = /^(?:https?:\/ \/ )?(?:[^@\/ \n ]+@)?(?:www\. )?([^:\/ \n ]+)/
7
7
8
8
HTTP_VERSION = 'HTTP/1.1'
@@ -14,6 +14,7 @@ class HTTP
14
14
port : 80 ,
15
15
ssl_port : 443 ,
16
16
accept : '*/*' ,
17
+ path : '/'
17
18
}
18
19
19
20
##
@@ -249,7 +250,7 @@ def parse_url(url, port)
249
250
@url [ :ssl_enabled ] = !!url [ /^(https)/ ]
250
251
251
252
@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 ]
253
254
else
254
255
raise ArgumentError
255
256
end
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def run_with_catching_error(&b)
16
16
end
17
17
18
18
assert ( "make a request" ) do
19
- http = HTTP . new ( "http://mruby.org/about/ " )
19
+ http = HTTP . new ( "http://mruby.org" )
20
20
response = http . request ( "GET" )
21
21
22
22
assert_equal response . nil? , false
You can’t perform that action at this time.
0 commit comments