Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply URL encoding to social media links #65

Open
D-Groenewegen opened this issue Oct 18, 2022 · 1 comment
Open

Apply URL encoding to social media links #65

D-Groenewegen opened this issue Oct 18, 2022 · 1 comment

Comments

@D-Groenewegen
Copy link

D-Groenewegen commented Oct 18, 2022

I noticed that the URLs fed to the Twitter links in the CanvasLink and ImageCropper plugins may not appear correctly.

Because Twitter links are in the format https://twitter.com/intent?text=...&url=...&hashtags=..., any URL search parameters that occur after ampersands (I append &manifest= and &canvas= myself) will be disregarded. It probably wouldn't hurt to escape the ampersands (src/components/utils.js).

Same thing for Facebook and Pinterest, though I'm not sure about the Whatsapp and email links.

Edit: this is proving to be harder than I imagined. The nesting of a URL within a URL within a URL, mad as it sounds, is not necessarily the problem here, but I just don't know how to replace the ampersands in utils.js. Neither encodeURI() nor encodeURIComponent() is helpful. I tried percent-encoding to %26, which works when testing Twitter links directly, but somewhere along the way the percent symbol itself gets encoded to %25, so I ended up with %2526 rather than %26.

@D-Groenewegen
Copy link
Author

I think I found a solution even though I'm wary of recommending it as a general one for everyone - I will leave that in your expert hands. What worked out for me, at least in the case of the Twitter, Facebook and Pinterest links, is the following:

  1. Edit src/components/utils.js and replace {imageUrl} with encodeURIComponent({imageUrl})
  2. Edit src/components/ShareButton.js and replace href: encodeURI(link) with plain href: link. (The double encoding I experienced above was of course due to encodeURI(). )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant