From a63eccf18839ecbfd35f45bd2da87b0c73a4cb2d Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 4 Oct 2023 22:46:28 -0600 Subject: [PATCH] Add url schemes to Zed --- crates/util/src/channel.rs | 26 ++++++++++++++++++++++++++ crates/zed/Cargo.toml | 3 +++ 2 files changed, 29 insertions(+) diff --git a/crates/util/src/channel.rs b/crates/util/src/channel.rs index 274fd576a0..89d42ffba6 100644 --- a/crates/util/src/channel.rs +++ b/crates/util/src/channel.rs @@ -1,6 +1,7 @@ use std::env; use lazy_static::lazy_static; +use url::Url; lazy_static! { pub static ref RELEASE_CHANNEL_NAME: String = if cfg!(debug_assertions) { @@ -15,6 +16,23 @@ lazy_static! { "stable" => ReleaseChannel::Stable, _ => panic!("invalid release channel {}", *RELEASE_CHANNEL_NAME), }; + + static ref URL_SCHEME: Url = Url::parse(match RELEASE_CHANNEL_NAME.as_str() { + "dev" => "zed-dev:/", + "preview" => "zed-preview:/", + "stable" => "zed:/", + // NOTE: this must be kept in sync with ./script/bundle and https://zed.dev. + _ => unreachable!(), + }) + .unwrap(); + static ref LINK_PREFIX: Url = Url::parse(match RELEASE_CHANNEL_NAME.as_str() { + "dev" => "http://localhost:3000/dev/", + "preview" => "https://zed.dev/preview/", + "stable" => "https://zed.dev/", + // NOTE: this must be kept in sync with https://zed.dev. + _ => unreachable!(), + }) + .unwrap(); } #[derive(Copy, Clone, PartialEq, Eq, Default)] @@ -41,4 +59,12 @@ impl ReleaseChannel { ReleaseChannel::Stable => "stable", } } + + pub fn url_scheme(&self) -> &'static Url { + &URL_SCHEME + } + + pub fn link_prefix(&self) -> &'static Url { + &LINK_PREFIX + } } diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index d4ac972a5d..7eb14559be 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -162,6 +162,7 @@ identifier = "dev.zed.Zed-Dev" name = "Zed Dev" osx_minimum_system_version = "10.15.7" osx_info_plist_exts = ["resources/info/*"] +osx_url_schemes = ["zed-dev"] [package.metadata.bundle-preview] icon = ["resources/app-icon-preview@2x.png", "resources/app-icon-preview.png"] @@ -169,6 +170,7 @@ identifier = "dev.zed.Zed-Preview" name = "Zed Preview" osx_minimum_system_version = "10.15.7" osx_info_plist_exts = ["resources/info/*"] +osx_url_schemes = ["zed-preview"] [package.metadata.bundle-stable] @@ -177,3 +179,4 @@ identifier = "dev.zed.Zed" name = "Zed" osx_minimum_system_version = "10.15.7" osx_info_plist_exts = ["resources/info/*"] +osx_url_schemes = ["zed"]