Repository: tauri-apps/tauri
File: core/tauri/src/window.rs (Rust)

Code before:
  pub fn start_dragging(&self) -> crate::Result<()> {
    self.window.dispatcher.start_dragging().map_err(Into::into)
  }
}

/// Webview APIs.
impl<R: Runtime> Window<R> {
  /// Returns the current url of the webview.
  // TODO: in v2, change this type to Result
  #[cfg(not(test))]
  pub fn url(&self) -> Url {
    self.window.dispatcher.url().unwrap()
  }

  #[cfg(test)]
  pub fn url(&self) -> Url {
    self.current_url.clone()
  }

  #[cfg(test)]
  pub(crate) fn navigate(&mut self, url: Url) {
    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 is_local = self.is_local_url(&current_url);

    let mut scope_not_found_error_message =
      ipc_scope_not_found_error_message(&self.window.label, current_url.as_str());
    let scope = if is_local {
      None
    } else {
      match self.ipc_scope().remote_access_for(&self, &current_url) {
        Ok(scope) => Some(scope),
        Err(e) => {
          if e.matches_window {
            scope_not_found_error_message = ipc_scope_domain_error_message(current_url.as_str());
          } else if e.matches_domain {
            scope_not_found_error_message = ipc_scope_window_error_message(&self.window.label);
          }
          None

Review comment (suggestion):
```suggestion
    self.manager.get_url().make_relative(current_url).is_some() || {
```

Code after:
  pub fn start_dragging(&self) -> crate::Result<()> {
    self.window.dispatcher.start_dragging().map_err(Into::into)
  }
}

/// Webview APIs.
impl<R: Runtime> Window<R> {
  /// Returns the current url of the webview.
  // TODO: in v2, change this type to Result
  #[cfg(not(test))]
  pub fn url(&self) -> Url {
    self.window.dispatcher.url().unwrap()
  }

  #[cfg(test)]
  pub fn url(&self) -> Url {
    self.current_url.clone()
  }

  #[cfg(test)]
  pub(crate) fn navigate(&mut self, url: Url) {
    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 is_local = self.is_local_url(&current_url);

    let mut scope_not_found_error_message =
      ipc_scope_not_found_error_message(&self.window.label, current_url.as_str());
    let scope = if is_local {
      None
    } else {
      match self.ipc_scope().remote_access_for(&self, &current_url) {
        Ok(scope) => Some(scope),
        Err(e) => {
          if e.matches_window {
            scope_not_found_error_message = ipc_scope_domain_error_message(current_url.as_str());
          } else if e.matches_domain {
            scope_not_found_error_message = ipc_scope_window_error_message(&self.window.label);
          }
          None