disqus / disqus-react

A React component for Disqus
MIT License
365 stars 46 forks source link

url wrong: url has two slash so that cannot be directed to the right page. #93

Closed Oyyko closed 3 years ago

Oyyko commented 3 years ago

Describe the bug

A clear and concise description of what the bug is.

url in xxx.disqus.com/admin/moderate/approved has two slash(//), which makes it unable to render the comment area. Besides, when using shared links, the same reason will make a same trouble. For more detials, please see here and here.

To Reproduce

Steps to reproduce the behavior:

  1. Go to casbin.org or crystal-lang.org
  2. leave a comment using disqus
  3. copy share link
  4. open share link
  5. The url will have two slash. For example: casbin.org//xxx/yyy/zz

Expected behavior

A clear and concise description of what you expected to happen.

The url should have only one slash. For example: "xxxxx.org/yy/zz"

Screenshots

If applicable, add screenshots to help explain your problem.

Please see the two PRs above.

tterb commented 3 years ago

@Oyyko This functionality is provided by the primary Disqus application and is outside the scope of this repo, but I have reproduced the issue and brought it to the team so we will try to get a fix out ASAP.

tterb commented 3 years ago

@Oyyko In the meantime, it looks like the share-links can be fixed by the site-owner by removing the backslash from the end of the Website URL at https://crystal-lang.disqus.com/admin/settings/general/

Oyyko commented 3 years ago

Thanks for your attention. However, I tried to remove the backslash but it seems that nothing happened. Really a strange bug.

lacardonap commented 3 years ago

I don't know if this is the right place, but I want to share a gif that shows how leaving two slashes in on the main page causes the page to reload infinitely.

Tested: Google Chrome Version 89.0.4389.90 (Official Build) (64-bit) Mozilla Firefox Version 87.0 (64-bit) infi_reload_page

hsluoyz commented 3 years ago

@Oyyko In the meantime, it looks like the share-links can be fixed by the site-owner by removing the backslash from the end of the Website URL at https://crystal-lang.disqus.com/admin/settings/general/

@tterb our URL was already without ending slash

image

hsluoyz commented 3 years ago

Hi @tterb , any update on the double slashes issue?

tterb commented 3 years ago

@hsluoyz @Oyyko A member of our support team investigated this issue and found that the reason for the double-slashes in URLs is a result of the url that is being set in the disqus_config containing double-slashes.

You can fix the issue on existing threads by updating the thread URLs using the URL Mapper and prevent the issue from occurring on new threads by ensuring the correct URL is being set in your disqus_config.

hsluoyz commented 3 years ago

Hi @tterb , thanks for your reply! About this part:

prevent the issue from occurring on new threads by ensuring the correct URL is being set in your disqus_config.

I think we don't have double slashes in our config: https://github.com/casbin/casbin-website/blob/master/website/static/js/disqus.js But it's still happening on new threads. Why?

const PAGE_IDENTIFIER = window.location.pathname;
const BASE_URL = 'https://casbin.org';
const PAGE_URL = BASE_URL + PAGE_IDENTIFIER;

/**
 *  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
 */
var disqus_config = function() {
  this.page.url = PAGE_URL; // Page's canonical URL variable
  this.page.identifier = PAGE_IDENTIFIER; // Page's unique identifier variable
};

function loadDisqus() {
  (function() {
    // DON'T EDIT BELOW THIS LINE
    s = document.createElement('script');
    s.src = 'https://casbin.disqus.com/embed.js';
    s.setAttribute('data-timestamp', +new Date());
    (document.head || document.body).appendChild(s);
  })();
}

function maybeLoadDisqus() {
  const hr = document.createElement('hr');
  const disqusContainer = document.createElement('disqus');
  disqusContainer.id = 'disqus_thread';
  const postContainer = document.querySelectorAll('.post article')[0];
  const isDocsPage = PAGE_IDENTIFIER.indexOf('/docs') !== -1;
  if (postContainer && isDocsPage) {
    postContainer.appendChild(hr);
    postContainer.appendChild(disqusContainer);
    loadDisqus();
  }
  // editor page
  if (PAGE_IDENTIFIER.indexOf('/editor') !== -1) {
    var el = document.getElementById('disqus');
    el.appendChild(hr);
    el.appendChild(disqusContainer);
    loadDisqus();
  }
}

document.addEventListener('DOMContentLoaded', function() {
  maybeLoadDisqus();
});

@ErikQQY can you take over this issue?

ErikQQY commented 3 years ago

@hsluoyz I am trying to solve this issue

tterb commented 3 years ago

I don't see an issue in the above code snippet that would cause new threads to have double backslashes in the URL and I'm not seeing any incorrectly formatted URLs at https://casbin.disqus.com/admin/discussions/.

Though, I did find the issue in crystal-lang.org here as the page.url begins with backslash.

hsluoyz commented 3 years ago

@tterb but for this page: https://casbin.disqus.com/admin/moderate/approved , you can see the double slashes here:

image

tterb commented 3 years ago

@hsluoyz Is that a thread that you've already updated the URL for using the URL Mapper I mentioned earlier? Also, could you provide a link to a newly created thread where you're seeing the issue?

ErikQQY commented 3 years ago

@tterb Thanks for your help, I have already updated the URL using URL Mapper, the issue is now solved.

Besides, when I use the URL Mapper, the csv file containing comments doesn't covers all of our comments, so I have to edit some links directly in admin portal.

hsluoyz commented 3 years ago

@tterb thanks for the help! I confirmed that the issue has been fixed. Feel free to close this issue :)