Fix/directory middleware URI escaping

This fixes an issue where the URLs included in the HTML on directory listings art not property encoded, and so files/directories that include special URL characters like `#` do not have functioning links. This properly calls `encodeURIComponent` on each part of the path.

Fixes #872