routing icon indicating copy to clipboard operation
routing copied to clipboard

Action parameters do not work correctly for null value

Open MartkCz opened this issue 1 year ago • 3 comments

Version: 3.1.0

Steps To Reproduce

Latte

{block content}
	{$type}
	{link this type: null}
	{link this type: articles}
	{link this type: random}
{/block}

Router

	public static function createRouter(): RouteList
	{
		$router = new RouteList;
		$router->addRoute('articles', [
			'presenter' => 'Home',
			'action' => 'default',
			'type' => 'articles'
		]);
		$router->addRoute('<presenter>/<action>[/<id>]', 'Home:default');
		return $router;
	}

Output

articles
/articles
/articles
/?type=random

Curl output curl -I http://localhost:9997/

HTTP/1.1 301 Moved Permanently
Host: localhost:9997
Location: http://localhost:9997/articles

Expected Behavior

articles
/
/articles
/?type=random

MartkCz avatar May 24 '24 12:05 MartkCz

This can be fixed by adding the following code before article route.

$router->addRoute('/', [
	'presenter' => 'Home',
	'action' => 'default',
	'type' => null,
]);

but I think it's undesirable behavior

MartkCz avatar May 28 '24 08:05 MartkCz

This should work:

$router->addRoute('articles ? type=<type>', [
	'presenter' => 'Home',
	'action' => 'default',
	'type' => 'articles'
]);

dg avatar May 28 '24 19:05 dg

It's not working. Still need to add router with null

MartkCz avatar May 31 '24 08:05 MartkCz