Fix livebook:// support on macOS and Windows (#3002)

This commit is contained in:
Wojtek Mach 2025-05-13 17:38:30 +02:00 committed by GitHub
parent 73c0f1b45c
commit caeb45f730
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 6 deletions

View file

@ -110,7 +110,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
for url in urls {
ElixirKit.API.publish("open", "file://\(url.path)")
if url.scheme! == "livebook" {
let string = url.absoluteString
ElixirKit.API.publish("open", string)
}
if url.scheme! == "file" {
// Livebook.Utils.expand_desktop_url/1 URL-escapes so here we pass unescaped URL
// as not to escape twice. This is not a problem for livebook:// url above.
let string = "file://\(url.path)"
ElixirKit.API.publish("open", string)
}
}
}

View file

@ -97,7 +97,7 @@ Section "Install Handlers"
DetailPrint "Registering livebook URL Handler"
DeleteRegKey HKCU "Software\Classes\livebook"
WriteRegStr HKCU "Software\Classes\livebook" "" "Livebook URL Protocol"
WriteRegStr HKCU "Software\Classes\livebook" "" "URL:Livebook Protocol"
WriteRegStr HKCU "Software\Classes\livebook" "URL Protocol" ""
WriteRegStr HKCU "Software\Classes\livebook\shell" "" ""
WriteRegStr HKCU "Software\Classes\livebook\shell\open" "" ""

View file

@ -18,7 +18,18 @@ static class LivebookMain
if (args.Length == 1 && args[0].StartsWith(prefix))
{
url = $"file://{args[0].Remove(0, prefix.Length)}";
url = args[0].Substring(prefix.Length);
var uri = new System.Uri(url);
if (uri.Scheme == "livebook")
{
url = uri.AbsoluteUri;
}
if (uri.Scheme == "file")
{
// Livebook.Utils.expand_desktop_url/1 URL-escapes so here we pass unescaped URL
// as not to escape twice. This is not a problem for livebook:// url above.
url = "file://" + uri.LocalPath;
}
}
var logPath = getLogPath();

View file

@ -13,13 +13,14 @@ echo "Setting registry to use $exe"
echo "!!!!!!"
echo
# .livemd
reg add "$root\\.livemd" //d "Livebook.LiveMarkdown" //f
reg add "$root\\Livebook.LiveMarkdown\\DefaultIcon" //d "$exe,1" //f
reg add "$root\\Livebook.LiveMarkdown\\shell\\open\\command" //d "$exe open:%1" //f
reg add "$root\\Livebook.LiveMarkdown\\shell\\open\\command" //d "\"$exe\" \"open:%1\"" //f
# livebook://
reg add "$root\\livebook" //d "URL:Livebook Protocol" //f
reg add "$root\\livebook" //v "URL Protocol" //f
reg add "$root\\Livebook\\DefaultIcon" //d "$exe,1" //f
reg add "$root\\livebook\\shell\\open\\command" //d "$exe open:%1" //f
reg add "$root\\livebook\\shell\\open\\command" //d "\"$exe\" \"open:%1\"" //f
dotnet run --no-build