mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-23 18:53:33 +03:00
* fix: check if url local with platform custom protocol, closes #7176 * Update core/tauri/src/window.rs
This commit is contained in:
parent
b66e7d60f2
commit
0fa0fa4ccf
@ -377,13 +377,17 @@ impl<R: Runtime> WindowManager<R> {
|
||||
pub(crate) fn get_url(&self) -> Cow<'_, Url> {
|
||||
match self.base_path() {
|
||||
AppUrl::Url(WindowUrl::External(url)) => Cow::Borrowed(url),
|
||||
#[cfg(windows)]
|
||||
_ => Cow::Owned(Url::parse("https://tauri.localhost").unwrap()),
|
||||
#[cfg(not(windows))]
|
||||
_ => Cow::Owned(Url::parse("tauri://localhost").unwrap()),
|
||||
_ => self.protocol_url(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn protocol_url(&self) -> Cow<'_, Url> {
|
||||
#[cfg(any(window, target_os = "android"))]
|
||||
return Cow::Owned(Url::parse("https://tauri.localhost").unwrap());
|
||||
#[cfg(not(any(window, target_os = "android")))]
|
||||
Cow::Owned(Url::parse("tauri://localhost").unwrap())
|
||||
}
|
||||
|
||||
fn csp(&self) -> Option<Csp> {
|
||||
if cfg!(feature = "custom-protocol") {
|
||||
self.inner.config.tauri.security.csp.clone()
|
||||
|
@ -1653,13 +1653,18 @@ impl<R: Runtime> Window<R> {
|
||||
self.current_url = url;
|
||||
}
|
||||
|
||||
fn is_local_url(&self, current_url: &Url) -> bool {
|
||||
self.manager.get_url().make_relative(current_url).is_some() || {
|
||||
let protocol_url = self.manager.protocol_url();
|
||||
current_url.scheme() == protocol_url.scheme() && current_url.domain() == protocol_url.domain()
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles this window receiving an [`InvokeMessage`].
|
||||
pub fn on_message(self, payload: InvokePayload) -> crate::Result<()> {
|
||||
let manager = self.manager.clone();
|
||||
let current_url = self.url();
|
||||
let config_url = manager.get_url();
|
||||
let is_local =
|
||||
config_url.make_relative(¤t_url).is_some() || current_url.scheme() == "tauri";
|
||||
let is_local = self.is_local_url(¤t_url);
|
||||
|
||||
let mut scope_not_found_error_message =
|
||||
ipc_scope_not_found_error_message(&self.window.label, current_url.as_str());
|
||||
|
Loading…
Reference in New Issue
Block a user