4

I'm trying to add a link that can be shared in WhatsApp:

For example:

"whatsapp://send?text=http://www.example.com/products/women/dresses?sessionid=34567&source=google.com"

But the link that is sent in WhatsApp is truncated from the '&' until the end. (the second parameter)

The same thing happens when I try:

"WhatsApp://send?text=http://www.example.com/prod&ucts/"

(note the '&' in the middle of the word 'prod&ucts') The text after the '&' is truncated.

Any suggestions why this is happening and how can I fix it?

stefanhorne
  • 1,619
  • 3
  • 16
  • 23
BIBI
  • 327
  • 1
  • 5
  • 15

1 Answers1

8

It'll be cutting it off because an '&' denotes a new query string parameter. You can fix it by encoding the string parameter in your URL using the encodeURI JavaScript function. The & character will encode to "%26".

DoctorMick
  • 6,703
  • 28
  • 26