fuel/core — Issue #863: generate_base_url misses trailing slash if script_name is empty
Author: mikebranderhorst
Created: 2012-03-07 15:53:00+00:00
State: open

If somehow script_name is empty, base_url misses a trailing slash.

https://github.com/fuel/core/blob/1.1/develop/classes/fuel.php#L308

```
/**
* Generates a base url.
*
* @return string the base url
*/
protected static function generate_base_url()
{
$base_url = '';
if(\Input::server('http_host'))
{
$base_url .= \Input::protocol().'://'.\Input::server('http_host');
}
if (\Input::server('script_name'))
{
$base_url .= str_replace('\\', '/', dirname(\Input::server('script_name')));

// Add a slash if it is missing
$base_url = rtrim($base_url, '/').'/';
}
return $base_url;
}
```

Shouldn't this be the correct code?

```

/**
* Generates a base url.
*
* @return string the base url
*/
protected static function generate_base_url()
{
$base_url = '';

if (\Input::server('http_host'))
{
$base_url .= \Input::protocol().'://'.\Input::server('http_host');
}

if (\Input::server('script_name'))
{
$base_url .= str_replace('\\', '/', dirname(\Input::server('script_name')));
}

// Add a slash if it is missing
return rtrim($base_url, '/').'/';
}
```