remove extra Uri conversion

This commit is contained in:
yggverse 2025-07-24 09:37:42 +03:00
parent c7a9a62566
commit fc87c4ce00
4 changed files with 13 additions and 13 deletions

View File

@ -152,6 +152,7 @@ fn handle(
) {
const EVENT_COMPLETED: &str = "Completed";
let uri = request.uri().clone();
let url = uri.to_string();
let server_certificate = this
.page
.profile
@ -161,7 +162,7 @@ fn handle(
this.client
.socket
.set_proxy_resolver(this.page.profile.proxy.matches(&uri).as_ref());
.set_proxy_resolver(this.page.profile.proxy.matches(&url).as_ref());
this.client.request_async(
request,
@ -172,7 +173,7 @@ fn handle(
this.page
.profile
.identity
.get(&uri.to_string()).map(|identity|identity.to_tls_certificate().unwrap()),
.get(&url).map(|identity|identity.to_tls_certificate().unwrap()),
server_certificate.map(|c|vec![c]),
{
let page = this.page.clone();
@ -192,7 +193,7 @@ fn handle(
use gtk::prelude::SocketConnectionExt;
let mut i = page.navigation.request.info.borrow_mut();
i
.set_request(Some(uri.to_string()))
.set_request(Some(url))
.set_socket(Some((
connection.socket_connection.local_address().unwrap(),
connection.socket_connection.remote_address().unwrap()

View File

@ -43,7 +43,9 @@ impl Nex {
.set_request(Some(uri.to_string()));
}
let path = uri.path(); // copy once
// copy once
let path = uri.path();
let url = uri.to_string();
if path.is_empty() {
// auto-append trailing slash to the root locations
@ -67,7 +69,7 @@ impl Nex {
}
let socket = SocketClient::new();
socket.set_proxy_resolver(self.page.profile.proxy.matches(&uri).as_ref());
socket.set_proxy_resolver(self.page.profile.proxy.matches(&url).as_ref());
socket.set_protocol(SocketProtocol::Tcp);
socket.set_timeout(30); // @TODO optional
@ -118,7 +120,7 @@ impl Nex {
}
});
socket.connect_to_uri_async(&uri.to_string(), 1900, Some(&cancellable.clone()), {
socket.connect_to_uri_async(&url, 1900, Some(&cancellable.clone()), {
let p = self.page.clone();
move |result| match result {
Ok(c) => {

View File

@ -138,7 +138,7 @@ impl Request {
// Indicate proxy connections
{
const C: &str = "accent";
if uri(e).is_some_and(|u| p.proxy.matches(&u).is_some()) {
if p.proxy.matches(&e.text()).is_some() {
e.set_css_classes(&[C])
} else {
e.remove_css_class(C)

View File

@ -4,10 +4,7 @@ mod rule;
use anyhow::Result;
use database::Database;
use gtk::{
gio::{ProxyResolver, SimpleProxyResolver},
glib::Uri,
};
use gtk::gio::{ProxyResolver, SimpleProxyResolver};
use ignore::Ignore;
use r2d2::Pool;
use r2d2_sqlite::SqliteConnectionManager;
@ -59,11 +56,11 @@ impl Proxy {
// Actions
pub fn matches(&self, request: &Uri) -> Option<ProxyResolver> {
pub fn matches(&self, request: &str) -> Option<ProxyResolver> {
for rule in self.rule.borrow().iter().filter(|r| r.is_enabled) {
if gtk::glib::Regex::match_simple(
&rule.request,
request.to_str(),
request,
gtk::glib::RegexCompileFlags::DEFAULT,
gtk::glib::RegexMatchFlags::DEFAULT,
) {