Skip to content

Commit

Permalink
valid url is returned even if script_name is empty. #180
Browse files Browse the repository at this point in the history
  • Loading branch information
smallstyle committed Jun 23, 2012
1 parent fbd355a commit 3667380
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tdiary/config.rb
Expand Up @@ -64,14 +64,15 @@ def base_url
end

def base_url_auto
return '' if @cgi.script_name.nil? || @cgi.script_name.empty?
return '' unless @cgi.script_name
begin
script_dirname = @cgi.script_name.empty? ? '' : File::dirname(@cgi.script_name)
if @cgi.https?
port = (@cgi.server_port == 443) ? '' : ':' + @cgi.server_port.to_s
"https://#{ @cgi.server_name }#{ port }#{File::dirname(@cgi.script_name)}/"
"https://#{ @cgi.server_name }#{ port }#{script_dirname}/"
else
port = (@cgi.server_port == 80) ? '' : ':' + @cgi.server_port.to_s
"http://#{ @cgi.server_name }#{ port }#{File::dirname(@cgi.script_name)}/"
"http://#{ @cgi.server_name }#{ port }#{script_dirname}/"
end.sub(%r|/+$|, '/')
rescue SecurityError
''
Expand Down

0 comments on commit 3667380

Please sign in to comment.