Fixes the detection of /api/ at the end of a url.