From c80a31af9c5156313ac3606acc3f57299c666a2b Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 27 Jan 2025 16:53:19 +0200 Subject: [PATCH] use const --- .../window/tab/item/page/navigation/request.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/browser/window/tab/item/page/navigation/request.rs b/src/app/browser/window/tab/item/page/navigation/request.rs index 5163b109..dd524ac8 100644 --- a/src/app/browser/window/tab/item/page/navigation/request.rs +++ b/src/app/browser/window/tab/item/page/navigation/request.rs @@ -13,6 +13,8 @@ use sqlite::Transaction; use std::{cell::Cell, rc::Rc}; const PLACEHOLDER_TEXT: &str = "URL or search term..."; +const PREFIX_DOWNLOAD: &str = "download:"; +const PREFIX_SOURCE: &str = "source:"; pub trait Request { // Constructors @@ -252,14 +254,14 @@ impl Request for Entry { strip_prefix(self.text()) } - /// Get request value in `download:` format + /// Get request value with formatted `download` prefix fn download(&self) -> GString { - gformat!("download:{}", self.strip_prefix()) + gformat!("{PREFIX_DOWNLOAD}{}", self.strip_prefix()) } - /// Get request value in `source:` format + /// Get request value with formatted `source` prefix fn source(&self) -> GString { - gformat!("source:{}", self.strip_prefix()) + gformat!("{PREFIX_SOURCE}{}", self.strip_prefix()) } /// Try get current request value as [Uri](https://docs.gtk.org/glib/struct.Uri.html) @@ -292,11 +294,11 @@ pub fn migrate(tx: &Transaction) -> Result<(), String> { /// Strip system prefix from request string /// * the `prefix` is not `scheme` fn strip_prefix(mut request: GString) -> GString { - if let Some(postfix) = request.strip_prefix("source:") { + if let Some(postfix) = request.strip_prefix(PREFIX_SOURCE) { request = postfix.into() }; - if let Some(postfix) = request.strip_prefix("download:") { + if let Some(postfix) = request.strip_prefix(PREFIX_DOWNLOAD) { request = postfix.into() };