Testing the path using charAt rather than slice