added check for trailing slashes as they dont appear on mac os