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

bugfix: tweets not rendering when they are paragraph element #2300

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ interface ContestProposalProps {

const transform = (node: HTMLElement): ReactNode => {
const element = node.tagName.toLowerCase();

if (element === "a") {
const href = node.getAttribute("href");
if (element === "a" || element === "p") {
const href = element === "a" ? node.getAttribute("href") : node.textContent;
const tweetUrlMatch = href && href.match(twitterRegex);

const isInsideList =
Expand Down
7 changes: 4 additions & 3 deletions packages/react-app-revamp/helpers/isContentTweet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ export const isContentTweet = (htmlContent: string): Tweet => {
let foundTweet = false;
let tweetId = "";

$("a").each(function () {
const href = $(this).attr("href");
const tweetUrlMatch = href && href.match(twitterRegex);
$("a, p").each(function () {
const element = this.tagName.toLowerCase();
const content = element === "a" ? $(this).attr("href") : $(this).text();
const tweetUrlMatch = content && content.match(twitterRegex);

const isInsideList = $(this).parents("li,ul,ol").length > 0;

Expand Down