route '/' handling differs
kenjis opened this issue · comments
kenjis commented
Sample code:
<?php
require __DIR__ . '/../vendor/autoload.php';
$mux = new Pux\Mux;
$mux->add('/', [ 'PageController', 'page1' ]);
$route = $mux->dispatch('/abc');
var_dump($route);
Result of 1.4.0:
NULL
Result of 1.5.0:
array(4) {
[0] =>
bool(false)
[1] =>
string(1) "/"
[2] =>
array(2) {
[0] =>
string(14) "PageController"
[1] =>
string(5) "page1"
}
[3] =>
array(0) {
}
}
Is this a bug or not?
Yo-An Lin commented
I think it's a bug.. orz will fix that soon
Yo-An Lin commented
OK, the prefix matching is used for Sub-mux dispatch. not sure the preferred behavior.
Yo-An Lin commented
This behaviour is inherent from golang's net/http
. however if we want to separate the comparing, we need to add one more condition for this.
kenjis commented
Current implementation, all undefined URL match the '/' route. So we can't treat as 404. It is not good.
Yo-An Lin commented
Agree
Yo-An Lin commented
Fixed in 2ebcafb...90abdcf
The current behaviour is:
- when callback is a submux (integer), use prefix matching
- or use full-match.
Yo-An Lin commented
Also added fallback tests