Sfoglia il codice sorgente

Use fragments instead of query params

Permalinks now just stick the base64 string into the
fragment portion of the URL, rather than using a
query parameter. This should reduce spam in the server
logs, and also keep scenes more private.
master
Fen Dweller 4 anni fa
parent
commit
ff2d6c14b2
1 ha cambiato i file con 10 aggiunte e 2 eliminazioni
  1. +10
    -2
      macrovision.js

+ 10
- 2
macrovision.js Vedi File

@@ -3002,7 +3002,15 @@ document.addEventListener("DOMContentLoaded", () => {


unitSelector.addEventListener("input", selectNewUnit); unitSelector.addEventListener("input", selectNewUnit);


param = new URL(window.location.href).searchParams.get("scene");
param = window.location.hash;

// we now use the fragment for links, but we should still support old stuff:

if (param.length > 0) {
param = param.substring(1);
} else {
param = new URL(window.location.href).searchParams.get("scene");
}


document.querySelector("#world").addEventListener("mousedown", e => { document.querySelector("#world").addEventListener("mousedown", e => {
// only middle mouse clicks // only middle mouse clicks
@@ -4418,7 +4426,7 @@ function b64DecodeUnicode(str) {


function linkScene() { function linkScene() {
loc = new URL(window.location); loc = new URL(window.location);
const link = loc.protocol + "//" + loc.host + loc.pathname + "?scene=" + b64EncodeUnicode(JSON.stringify(exportScene()));
const link = loc.protocol + "//" + loc.host + loc.pathname + "#" + b64EncodeUnicode(JSON.stringify(exportScene()));
window.history.replaceState(null, "Macrovision", link); window.history.replaceState(null, "Macrovision", link);
try { try {
navigator.clipboard.writeText(link); navigator.clipboard.writeText(link);


Loading…
Annulla
Salva