Fix #874

Should fix #874.

Just added encodeURIComponent() around the directory so #?&/ aren't interpreted as HTML.