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

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

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