Router fixes

Replaced substring with slice, checking pathname with “/api/“ and
“.json”. Removed some returns.