Fix cleanPath not encoding single quotes

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