Fix realpath() for Windows: ignore trailing slashes