Fix undefined index warning in router

Fixes #7887

cc @DeepDiver1975 @PVince81