From 2a569e65f489eb1fc1215ebd5069192e755763be Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Mon, 23 Dec 2024 23:14:32 -0600 Subject: [PATCH] Fix Simple 3D "Open sample project" button --- src-main/windows/editor.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src-main/windows/editor.js b/src-main/windows/editor.js index 9fe5ac3a..6296f748 100644 --- a/src-main/windows/editor.js +++ b/src-main/windows/editor.js @@ -615,15 +615,23 @@ class EditorWindow extends ProjectRunningWindow { } handleWindowOpen (details) { + const url = new URL(details.url); + const params = new URLSearchParams(url.search); + // Open extension sample projects in-app - const extensionSamplesMatch = details.url.match( - /^tw-editor:\/\/\.\/gui\/editor\?project_url=(https:\/\/extensions\.turbowarp\.org\/samples\/.+\.sb3)$/ - ); - if (extensionSamplesMatch) { - EditorWindow.openFiles([extensionSamplesMatch[1]], false, ''); - return { - action: 'deny' - }; + if ( + url.protocol === 'tw-editor:' && + url.host === '.' && + params.has('project_url') + ) { + const projectUrl = params.get('project_url'); + const parsedFile = parseOpenedFile(projectUrl, null); + if (parsedFile.type === TYPE_SAMPLE) { + new EditorWindow(parsedFile, null); + return { + action: 'deny' + }; + } } // Open extension documentation in-app