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

fix(twitter-url): twitter vernacular url encode bug #194

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sivteck
Copy link
Contributor

@sivteck sivteck commented Sep 24, 2021

Description

When there is vernacular text in the shared article url, twitter breaks the output from encodeURIComponent , see the linked issue for description

Fixes https://github.com/quintype/madrid/issues/4105

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

The fix is to just use encodeURI function instead

Differences between these functions are documented here,

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#description

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@sivteck sivteck changed the title twitter vernacular url encode bug fix(twitter-url): twitter vernacular url encode bug Sep 24, 2021
@@ -33,7 +33,7 @@ class SocialShareBase extends React.Component {

return React.createElement(this.props.template, Object.assign({
fbUrl: `https://www.facebook.com/sharer.php?u=${encodeURIComponent(fullUrl)}`,
twitterUrl: `https://twitter.com/intent/tweet?url=${encodeURIComponent(fullUrl)}&text=${encodeURIComponent(this.props.title)}&hashtags=${hashtags}`,
twitterUrl: `https://twitter.com/intent/tweet?url=${encodeURI(fullUrl)}&text=${encodeURIComponent(this.props.title)}&hashtags=${hashtags}`,
Copy link
Contributor

@Athira001 Athira001 Sep 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can pass the encoded Url from the app level?

<SocialShare
     template={ShareAllTemplate}
     title={storyData.headline}
     fullUrl={encodeURI(story.url)}
  />

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it is easier to fix in the implementation level rather than modifying ever use case in the app level

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, Prothomalo and Prabhatkbhar, They already passing it in encoded form. @sivteck

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome

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

Successfully merging this pull request may close these issues.

3 participants