suggestion by freewil to use encodeURI instead of string.replace to encode other special characters