fuel / core

Fuel PHP Framework - The core of the Fuel v1 framework
http://fuelphp.com
811 stars 346 forks source link

Uri::main() shoul return base URL only #30

Closed dhrrgn closed 13 years ago

dhrrgn commented 13 years ago

Entered by Juan Treminio on 4/13/11

fuel/core/classes/uri.php:

/**
 * Gets the current URL, including the BASE_URL
 *
 * @param    string    the url
 */
public static function main()
{
    return static::create(\Request::main()->uri->uri);
}

/**
 * Gets the current URL, including the BASE_URL
 *
 * @param    string    the url
 */
public static function current()
{
    return static::create();
}

Uri::main() should return ONLY main URL.

Example, if my website is on http://fuel.com/, Uri::main() should return only "http://fuel.com/", but it's returning the same thing as Uri::current(), which is the base URL plus controller.

Uri::main in welcome/index is currently returning:

http://fuel.com/welcome/index/

For now I've simply extend Uri:

static function base()
{
    return \Config::get('base_url');
}

Stuart Hutchinson responded

According to the docs, URI:current() does the following:

The current method allows you to fetch the current URL, including the base URL inside HMVC pattern.

whereas URI::main() does the following:

The main method allows you to fetch the current URL, including the base URL.

I think this should probably be a feature if adding a function such as URI::base() to the class is desired.

dhrrgn commented 13 years ago

Labeling as Bug

agentphoenix commented 13 years ago

+1

I'd definitely like to see something in the URI class to pull back just the base URL instead of having to go out and pull a config item every time.