diff --git a/static/js/compat.js b/static/js/compat.js index ad4c44b..0bc9e37 100644 --- a/static/js/compat.js +++ b/static/js/compat.js @@ -2,14 +2,31 @@ export function hashCompat(){ if (window.location.hash) { - let match = window.location.hash.match(/^#\/(\d*)\/(\d*)\/(\d*)$/m); - if (match) { - window.location.hash = `#!/map/0/${match[1]}/${match[2]}/${match[3]}`; + + const parts = window.location.hash.replace("#", "").split("/"); + if (parts.length == 0){ + //invalid + return; } - match = window.location.hash.match(/^#\/(\d*)\/(\d*)\/(\d*)\/(\d*)$/m); - if (match) { - window.location.hash = `#!/map/${match[1]}/${match[2]}/${match[3]}/${match[4]}`; + if (parts[0] == "map"){ + //new link + return; + } + + if (isNaN(+parts[0])){ + //NaN + return; + } + + if (parts.length == 3){ + //#1799.5/399/10 + window.location.hash = `#!/map/0/${parts[0]}/${parts[1]}/${parts[2]}`; + } + + if (parts.length == 4) { + //#0/-1799.5/399/10 + window.location.hash = `#!/map/${parts[0]}/${parts[3]}/${parts[1]}/${parts[2]}`; } } }