Replaced use of deprecated escape() with encodeURLComponent()