mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-03-22 19:05:56 -04:00
Merge pull request #2325 from benjiwheeler/hash-redirect
redirect hash urls to url pathnames
This commit is contained in:
commit
95fb947c08
1 changed files with 17 additions and 0 deletions
|
@ -778,6 +778,23 @@ const ConnectedPreview = connect(
|
|||
mapDispatchToProps
|
||||
)(Preview);
|
||||
|
||||
// replace old Scratch 2.0-style hashtag URLs with updated format
|
||||
if (window.location.hash) {
|
||||
let pathname = window.location.pathname;
|
||||
if (pathname.substr(-1) !== '/') {
|
||||
pathname = `${pathname}/`;
|
||||
}
|
||||
if (window.location.hash === '#editor') {
|
||||
history.replaceState({}, document.title,
|
||||
`${pathname}editor${window.location.search}`);
|
||||
}
|
||||
if (window.location.hash === '#fullscreen') {
|
||||
history.replaceState({}, document.title,
|
||||
`${pathname}fullscreen${window.location.search}`);
|
||||
}
|
||||
}
|
||||
|
||||
// initialize GUI by calling its reducer functions depending on URL
|
||||
GUI.setAppElement(document.getElementById('app'));
|
||||
const initGuiState = guiInitialState => {
|
||||
const pathname = window.location.pathname.toLowerCase();
|
||||
|
|
Loading…
Reference in a new issue