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

Strip HTML tags before sharing in Facebook #55

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jgrossi
Copy link
Contributor

@jgrossi jgrossi commented Jul 17, 2017

When sharing to Facebook it writes HTML tags, like <strong> or even <h3, for example.

This will strip all HTML tags before sharing to Facebook.

Copy link
Collaborator

@shri3k shri3k left a comment

Choose a reason for hiding this comment

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

Left a comment on the confused line. I'd like to know the context of using self.htmlSelection instead of self.textSelection here. I'd prefer others to review this as well, maybe they have some background on using that.

@@ -232,6 +232,7 @@
this.shareFacebook = function(e) {
e.preventDefault();
var text = self.htmlSelection.replace(/<p[^>]*>/ig,'\n').replace(/<\/p>| /ig,'').trim();
text = text.replace(/<\/?[^>]+(>|$)/g, ""); // Remove HTML tags, like <h3>foo</h3>bar => foobar
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch. However, I'm not sure why self.htmlSelection was chosen here. I think self.textSelection would make a lot more sense as it already gives us just plain text. @xdamman, would you like to chime in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, make sense. Using textSelection makes more sense than htmlSelection, and I guess it'll solve the problem anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to send a PR with the textSelection change if it's urgent. I think it's safe to say that textSelection is the better solution to this.

@shri3k shri3k added the bug label Jul 18, 2017
@shri3k shri3k force-pushed the develop branch 2 times, most recently from 2b84818 to eb2c201 Compare December 4, 2018 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants