From f55e7f726ae22195b35a5bbfd39fcf8e1be8f9d6 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Fri, 5 Sep 2025 18:05:46 +0300 Subject: [PATCH] fix query param stripping from protocol before match --- dns/src/gurt_server.rs | 2 +- protocol/library/src/server.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dns/src/gurt_server.rs b/dns/src/gurt_server.rs index ca53b26..14210d5 100644 --- a/dns/src/gurt_server.rs +++ b/dns/src/gurt_server.rs @@ -127,6 +127,7 @@ impl GurtHandler for AppHandler { }; log::info!("Handler started for {} {} from {}", ctx.method(), ctx.path(), ctx.remote_addr); + log::info!("Handler type will be: {:?}", handler_type); let result = match handler_type { HandlerType::Index => routes::index(app_state).await, @@ -240,7 +241,6 @@ pub async fn start(cli: crate::Cli) -> std::io::Result<()> { .route(Route::post("/auth/create-domain-invite"), AppHandler { app_state: app_state.clone(), rate_limit_state: None, handler_type: HandlerType::CreateDomainInvite }) .route(Route::post("/auth/redeem-domain-invite"), AppHandler { app_state: app_state.clone(), rate_limit_state: None, handler_type: HandlerType::RedeemDomainInvite }) .route(Route::get("/auth/domains"), AppHandler { app_state: app_state.clone(), rate_limit_state: None, handler_type: HandlerType::GetUserDomains }) - .route(Route::get("/auth/domains/*"), AppHandler { app_state: app_state.clone(), rate_limit_state: None, handler_type: HandlerType::GetUserDomains }) .route(Route::post("/domain"), AppHandler { app_state: app_state.clone(), rate_limit_state: Some(rate_limit_state), handler_type: HandlerType::CreateDomain }) .route(Route::get("/domain/*"), AppHandler { app_state: app_state.clone(), rate_limit_state: None, handler_type: HandlerType::GetDomain }) .route(Route::post("/domain/*"), AppHandler { app_state: app_state.clone(), rate_limit_state: None, handler_type: HandlerType::CreateDomainRecord }) diff --git a/protocol/library/src/server.rs b/protocol/library/src/server.rs index 055b73c..c744cd2 100644 --- a/protocol/library/src/server.rs +++ b/protocol/library/src/server.rs @@ -129,8 +129,15 @@ impl Route { } pub fn matches_path(&self, path: &str) -> bool { - self.path_pattern == path || - (self.path_pattern.ends_with('*') && path.starts_with(&self.path_pattern[..self.path_pattern.len()-1])) + // Strip query parameters from path for matching + let path_without_query = if let Some(query_pos) = path.find('?') { + &path[..query_pos] + } else { + path + }; + + self.path_pattern == path_without_query || + (self.path_pattern.ends_with('*') && path_without_query.starts_with(&self.path_pattern[..self.path_pattern.len()-1])) } }