From: Yamagishi Kazutoshi Date: Fri, 30 Jun 2017 03:37:41 +0000 (+0900) Subject: Replace state to /web when root path (#4009) X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=a27879c0cf89d99fb79e2ffbe7ecfdf72733a1c4;p=mastodon.git Replace state to /web when root path (#4009) --- diff --git a/app/javascript/mastodon/main.js b/app/javascript/mastodon/main.js index 02e0f56f9..aca64c075 100644 --- a/app/javascript/mastodon/main.js +++ b/app/javascript/mastodon/main.js @@ -20,6 +20,14 @@ function main() { require.context('../images/', true); + if (window.history && history.replaceState) { + const { pathname, search, hash } = window.location; + const path = pathname + search + hash; + if (!(/^\/web[$/]/).test(path)) { + history.replaceState(null, document.title, `/web${path}`); + } + } + onDomContentLoaded(() => { const mountNode = document.getElementById('mastodon'); const props = JSON.parse(mountNode.getAttribute('data-props'));