最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Arabic Hashtag in Facebook Sharer Adds Unwanted Characters (e.g., ?__eep__=6) - Stack Overflow

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论