Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Types/Entities/Level/Editor/LevelEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,8 @@ Share -> open dialog w/ serialized JSON with edit: false, name: "Custom"

function onShareButtonClicked() {
const serialized = serialize('CUSTOM_LEVEL')
const url =
location.origin +
'?' +
LZString.compressToBase64(JSON.stringify(serialized))
const compressed = LZString.compressToBase64(JSON.stringify(serialized))
const url = `${location.origin}?data=${compressed}`
ui.puzzleLink.value = url
showDialog(ui.editorSharingLinkDialog)
}
Expand Down
2 changes: 1 addition & 1 deletion Types/Entities/Level/Level.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ function Level(spec) {
history.pushState(
null,
null,
'?' + LZString.compressToBase64(JSON.stringify(serialized)),
'?data=' + LZString.compressToBase64(JSON.stringify(serialized)),
)
// console.log('Writing to URL:', serialized)
}
Expand Down
7 changes: 4 additions & 3 deletions Types/Entities/World.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,15 @@ function World(spec) {
function getUrlData() {
const url = new URL(location)

if (url.search) {
if (url.searchParams.has('data')) {
try {
const compressedData = location.href.split('data=')[1]?.split('&')[0]
const urlData = JSON.parse(
LZString.decompressFromBase64(url.search.slice(1)),
LZString.decompressFromBase64(compressedData),
)
return urlData
} catch (err) {
console.error('Error loading url:', err)
console.error('Error loading URL data:', err)
// TODO: Maybe switch to modal
alert('Sorry, this URL is malformed :(')
}
Expand Down