How to fix the problem of URL not showing properly in Gmail?

Description

From the website when we place an order the notification email is send to the corresponding customer. The email contains the item details. If the items having personalization with images or uploading any logo to the items , at that times the URL of the uploaded images are shown in email.

Cases

case1: By clicking the URL it shows page not found.

case2: The URL is appears as half link and half text.

Solution

Mainly these types of errors are coming due to , when we assign a value to the varibale that is used for the uploading image , it contains spaces.That spaces causes these issues.

So remove the unwanted spaces.

For that we can use the below codes

1.str.replace(/\s/g, '')
2.str.replace(/\s+/g, '')
3.If you change the replacement string to '#'
var str = '  A B  C   D EF ';
console.log(str.replace(/\s/g, '#'));  // ##A#B##C###D#EF#
console.log(str.replace(/\s+/g, '#')); // #A#B#C#D#EF#
4.text.replace(/^\s+|\s+$/gm,'');
5.str.replaceAll(' ', '') -> Its removes all spaces from the string.

Leave a comment

Your email address will not be published. Required fields are marked *