diff --git a/website/static/js/app.js b/website/static/js/app.js index b6917ef..4df1083 100644 --- a/website/static/js/app.js +++ b/website/static/js/app.js @@ -610,11 +610,14 @@ function loadFromUrl() { if (shareParam) { try { const decoded = base64urlDecode(shareParam); + // Split at the first newline character + const [filePath, source] = decoded.split(/\n([\s\S]*)$/); + document.getElementById('file-path').value = filePath; const textarea = document.getElementById('mlf-editor'); if (textarea) { - textarea.value = decoded; - updateLineNumbers(decoded); - updateHighlighting(decoded); + textarea.value = source; + updateLineNumbers(source); + updateHighlighting(source); } } catch (error) { console.error('Failed to load shared code:', error); @@ -624,8 +627,9 @@ function loadFromUrl() { } function handleShare() { + const filePath = document.getElementById('file-path').value; const source = getEditorContent(); - const encoded = base64urlEncode(source); + const encoded = base64urlEncode(`${filePath}\n${source}`); // Build share URL const baseUrl = window.location.origin + window.location.pathname;