Embedded topic comments are missing if containing page's URL includes a fragment identifier

Discourse’s ability to embed comments from a topic into an external site is wonderful and works amazingly well.

I did run into a small issue that I would consider a bug:

If I have a page on an external site http://example.com/test.html, all comments from the companion topic are displayed in the iframe, as expected. If I visit the same page with a fragment identifier appended to the URL (e.g. http://example.com/test.html#references or even http://example.com/test.html#), the comments do not display. It seems like this is because the companion pairing is based on an exact string match. In practice, I think an exact string match is too strict.

I would expect the following external site URLs to all embed the same set of comments:

  1. http://example.com/test.html
  2. http://example.com/test.html#
  3. http://example.com/test.html#foo
1 Like

The above solution may help you. It will remove query strings too. So you have to remove the ? character. Anyway I will check your suggestion. If you can create a PR that will be more helpful.

2 Likes

Modifying the discourseEmbedUrl in the embed code sounds like a simple solution here. Thanks!