here my sample FastRoute for slim3 :
$app->get('/api/search/[{domaine}[/{notused:.+}]]', function ($request, $response, $args) {
return $this->renderer->render($response, 'index.phtml', $args);
});
with this FastRoute "regex" ([{domaine}[/{notused:.+}]]), I match :
/api/search/sample.com
/api/search/sample.com/test
/api/search/
And $args['domaine'] return "sample.com".
but I want to match this too :
/api/search/http://sample.com
/api/search/https://sample.com
add new route like this work :
$app->get('/api/search/http://[{domaine}[/{notused:.+}]]' ...
$app->get('/api/search/https://[{domaine}[/{notused:.+}]]' ...
But it's better to have just one line.
Any ideas ?
It would be better when you use an url encoded url as query parameter.
But when you really what to use this, you could regex the http(s) part as well
that means it requires
http
and then have 0-1s
.