var discourseUrl = window.hackdash && window.hackdash.discourseUrl;
if (discourseUrl) {
  DiscourseEmbed = {
    discourseEmbedUrl: window.location.href,
    discourseUrl: discourseUrl
  };
  // The only way to re-execute Discourse embedding script seems to be to re-insert it.
  $("#discourse-comments").remove();
  $("#discourse-embed-script").remove();
  $(".discourse-ctn").append($("<div>", {
    "id": "discourse-comments"
  }));
  $("head").append($("<script>", {
    "async": true,
    "id": "discourse-embed-script",
    "src": DiscourseEmbed.discourseUrl + 'javascripts/embed.js',
    "type": "text/javascript"
  }));
}

var discourseUrl = window.hackdash && window.hackdash.discourseUrl;
if (discourseUrl) {
  DiscourseEmbed = {
    discourseEmbedUrl: [location.protocol, '//', location.host, location.pathname].join(''),
    discourseUrl: discourseUrl
  };
  // The only way to re-execute Discourse embedding script seems to be to re-insert it.
  $("#discourse-comments").remove();
  $("#discourse-embed-script").remove();
  $(".discourse-ctn").append($("<div>", {
    "id": "discourse-comments"
  }));
  $("head").append($("<script>", {
    "async": true,
    "id": "discourse-embed-script",
    "src": DiscourseEmbed.discourseUrl + 'javascripts/embed.js',
    "type": "text/javascript"
  }));
}

Remove query and hash from Discourse URLs.
Remove query and hash from Discourse URLs.

In some cases, hackdash adds a query to the URL of the projects. This patch ignore the query, to ensure that 2 different Discourse forums are not created for the same project.