# Eingebettete Themenkommentare fehlen, wenn die URL der übergeordneten Seite einen Fragment-Identifikator enthält

**URL:** https://meta.discourse.org/t/embedded-topic-comments-are-missing-if-containing-pages-url-includes-a-fragment-identifier/93235
**Category:** Bug
**Created:** [26. Juli 2018 um 21:00 UTC](https://meta.discourse.org/t/embedded-topic-comments-are-missing-if-containing-pages-url-includes-a-fragment-identifier/93235 "2018-07-26T21:00:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![aribadernatal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aribadernatal/32/527594_2.png) [@aribadernatal](https://meta.discourse.org/u/aribadernatal)
#### Post date: [26. Juli 2018 um 21:00 UTC](https://meta.discourse.org/t/embedded-topic-comments-are-missing-if-containing-pages-url-includes-a-fragment-identifier/93235/1 "2018-07-26T21:00:40Z")

</div>

Discourse’s ability to [embed comments from a topic into an external site](https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963) 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](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](http://example.com/test.html#references) or even [http://example.com/test.html#](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](http://example.com/test.html)
2. [http://example.com/test.html#](http://example.com/test.html#)
3. [http://example.com/test.html#foo](http://example.com/test.html#foo)

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [26. Juli 2018 um 21:32 UTC](https://meta.discourse.org/t/embedded-topic-comments-are-missing-if-containing-pages-url-includes-a-fragment-identifier/93235/2 "2018-07-26T21:32:31Z")

</div>

> [@discourseEmbedUrl and Joomla](https://meta.discourse.org/t/discourseembedurl-and-joomla/92039/2):
>
> You can use the below code. It will remove the query string from URL.
> 
> `discourseEmbedUrl: window.location.href.split(/[?#]/)[0] };`

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.

---

<div class="post-metadata">

### Author: ![aribadernatal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aribadernatal/32/527594_2.png) [@aribadernatal](https://meta.discourse.org/u/aribadernatal)
#### Post date: [26. Juli 2018 um 22:00 UTC](https://meta.discourse.org/t/embedded-topic-comments-are-missing-if-containing-pages-url-includes-a-fragment-identifier/93235/3 "2018-07-26T22:00:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [27. Juli 2018 um 12:33 UTC](https://meta.discourse.org/t/embedded-topic-comments-are-missing-if-containing-pages-url-includes-a-fragment-identifier/93235/4 "2018-07-27T12:33:24Z")

</div>


