Fix cleanPath not encoding single quotes (fixes #812)

encodeURIComponent doesn't encode single quotes, so this amends the
cleanPath function with a manual replacing of single quotes.