3

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?

AproposArmadillo
  • 1,533
  • 3
  • 16
  • 22
BIBI
  • 317
  • 4
  • 15

1 Answers1

6

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,553
  • 25
  • 24