Fix #798.
Follow what has been done in other middlewares, like CleanPath
And some middlewares may have the same issue too, I don't check them.