klein / klein.php

A fast & flexible router
MIT License
2.66k stars 290 forks source link

Case insensitive #350

Closed sm2017 closed 7 years ago

sm2017 commented 7 years ago

How can I do this?

$klein->respond('/check/[:name]', function ($request) {
    return 'Hello ' . $request->name;
});

/check must be case insensitive but [:name] is case sensitive Also /check/test is working but /check/test/ is 404 I want to have both

sm2017 commented 7 years ago

Any idea?

ghost commented 7 years ago

@sm2017

require_once 'vendor/autoload.php';

use Klein\Klein;

$app = new Klein();
$app->respond('/check/[:name]/?', function ($request) {
    return 'Hello ' . $request->name;
});
$app->dispatch();
sm2017 commented 7 years ago

@jahak7 thanks for your reply

/check must be case insensitive but in your code is case sensitive

thinsoldier commented 7 years ago

Loop through the various url related values within $_SERVER and force them to be lowercase before your create your $klein object.

sm2017 commented 7 years ago

Ok , thanks