thecodeholic / tc-php-mvc-core

103 stars 30 forks source link

Router Issue #6

Closed Steevoh120 closed 2 years ago

Steevoh120 commented 2 years ago

I defined a route as $app->router->get('/users', [Users::class, 'users']); , However from my browser '/users/ returns the same as '/users' while this should throw 404 not Found. What causes this?

virtual-designer commented 2 years ago

https://github.com/thecodeholic/tc-php-mvc-core/blob/master/Router.php#L53 is causing this. But I don't think that this is an issue.

Steevoh120 commented 2 years ago

Is there a way to stop this from happenning?

virtual-designer commented 2 years ago

Is there a way to stop this from happenning?

Sure! In your framework, just remove line 53 from Router.php.

Steevoh120 commented 2 years ago

Is there a way to stop this from happenning?

Sure! In your framework, just remove line 53 from Router.php.

when I remove it $app->router->get('/users/{id}', [Users::class, 'users']); now throws 404 not found

virtual-designer commented 2 years ago

Is there a way to stop this from happenning?

Sure! In your framework, just remove line 53 from Router.php.

when I remove it $app->router->get('/users/{id}', [Users::class, 'users']); now throws 404 not found

Hmm. Then you can edit line 53 like this: $url = ltrim($url, '/');

Steevoh120 commented 2 years ago

Is there a way to stop this from happenning?

Sure! In your framework, just remove line 53 from Router.php.

when I remove it $app->router->get('/users/{id}', [Users::class, 'users']); now throws 404 not found

Hmm. Then you can edit line 53 like this: $url = ltrim($url, '/');

Yes, This is it. Thank you

virtual-designer commented 2 years ago

Is there a way to stop this from happenning?

Sure! In your framework, just remove line 53 from Router.php.

when I remove it $app->router->get('/users/{id}', [Users::class, 'users']); now throws 404 not found

Hmm. Then you can edit line 53 like this: $url = ltrim($url, '/');

Yes, This is it. Thank you

Most welcome.