diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js index 086719bc501cf87738753aa1449c48f21ed13a9b..9495ae918e334db4980056bc976c9cecc8c3cbb0 100644 --- a/src/scripts/coopstarter.js +++ b/src/scripts/coopstarter.js @@ -555,7 +555,8 @@ document.addEventListener("DOMContentLoaded", event => { shareLink.addEventListener("populate", function (e) { var regexContributor = /contributor/g var regexSearcher = /searcher/g - var valUrl = window.location.href.replace(regexContributor, 'public').replace(regexSearcher, 'public') + var regexContributorDb = /contributor-database\/contributor-database-resource-detail/g + var valUrl = window.location.href.replace(regexContributorDb,'public-resource-detail').replace(regexContributor, 'public').replace(regexSearcher, 'public') shareLink.querySelector('.twshare').setAttribute("href", "https://twitter.com/intent/tweet?text=Check%20this%20resource%20from%20Coopedia%20:%20&original_referer="+valUrl+"&ref_src=twsrc%5Etfw&tw_p=tweetbutton&&url="+valUrl+"&"); }); }); diff --git a/src/scripts/dispatch-space-n-user.js b/src/scripts/dispatch-space-n-user.js index 9ec481fcd62d0ecd9dc7d545cf8bde10a5e41a1a..36650f9e94ea2e9232aaff59aef0aaeb9da379e7 100644 --- a/src/scripts/dispatch-space-n-user.js +++ b/src/scripts/dispatch-space-n-user.js @@ -74,28 +74,27 @@ class CoopStarterLoginComponent extends HTMLElement { } } } - //If the url asked pointed to a resource - // if (window.location.href.indexOf('resource-detail') > -1) { - // var newUrl = window.location.href.replace(/\/([a-z]+)-dashboard\/([a-z]+)-resource-detail/, `/${userPrefix}-dashboard/${userPrefix}-resource-detail`) + /* if (window.location.href.indexOf('resource-detail') > -1) { + var newUrl = window.location.href.replace(/\/([a-z]+)-dashboard\/([a-z]+)-resource-detail/, `/${userPrefix}-dashboard/${userPrefix}-resource-detail`) - // // If the url is different after the treatment, we reload with the good url - // if (newUrl !== window.location.href) { - // var newRoute = new URL(newUrl).pathname.replace(/^\/([a-z]{2})\//, ""); - // window.dispatchEvent( - // new CustomEvent('requestNavigation', { - // detail: { - // route: newRoute.split(/\/(.*?)\//)[1], - // resource: { "@id": this.decodeId(newRoute.split(/@(.+)/)[1]) } - // } - // }) - // ); - // window.location.href = newUrl; - // // loader.toggleAttribute('hidden', true); - // } else { - // loader.toggleAttribute('hidden', true); - // } - // } else { + // If the url is different after the treatment, we reload with the good url + if (newUrl !== window.location.href) { + var newRoute = new URL(newUrl).pathname.replace(/^\/([a-z]{2})\//, ""); + window.dispatchEvent( + new CustomEvent('requestNavigation', { + detail: { + route: newRoute.split(/\/(.*?)\//)[1], + resource: { "@id": this.decodeId(newRoute.split(/@(.+)/)[1]) } + } + }) + ); + window.location.href = newUrl; + // loader.toggleAttribute('hidden', true); + } else { + loader.toggleAttribute('hidden', true); + } + } else {*/ // User is a contributor if (userPrefix === "contributor") { loader.toggleAttribute('hidden', true);