admin管理员组

文章数量:1334329

I'm trying to implement a Facebook share button in my Next.js application with a pre-filled Arabic hashtag, but I'm running into an issue.

Here is the code I'm using:

const handleShare = (e) => {
  e.preventDefault();
  if (score) {
    const shareParams = new URLSearchParams({
      u: shareUrl,
      hashtag: "#هاشتاگێکی_دیاریکراو",
    }).toString();

    const fbShareUrl = `.php?${shareParams}`;

    // Open share dialog
    window.open(
      fbShareUrl,
      "_blank",
      "width=600,height=400,left=" +
        (window.innerWidth - 600) / 2 +
        ",top=" +
        (window.innerHeight - 400) / 2
    );
  }
};

The issue is that when I click the hashtag in Facebook after sharing the post, the URL of the hashtag changes. For example, this is what I get:

The added ?__eep__=6 parameter breaks the hashtag. If I manually remove ?eep=6 from the URL in the browser, the hashtag works correctly.

I have tried these approaches:

  1. Encoding the hashtag (encodeURIComponent("#هاشتاگێکی_دیاریکراو"))
  2. Removing the # sign

Still none of these works.

本文标签: javascriptArabic Hashtag in Facebook Sharer Adds Unwanted Characters (egeep6)Stack Overflow