♻️ Simple & Efficient Gemini-to-HTTP Proxy fuwn.net
proxy gemini-protocol protocol gemini http rust
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(response): Robust path pattern matching

Fuwn ed551415 01b1a0a1

+25 -15
+25 -15
src/response.rs
··· 269 269 } 270 270 271 271 fn path_matches_pattern(pattern: &str, path: &str) -> bool { 272 + if !pattern.contains('*') { 273 + return path == pattern; 274 + } 275 + 272 276 let parts: Vec<&str> = pattern.split('*').collect(); 273 - let mut position = 0; 277 + let mut position = if pattern.starts_with('*') { 278 + 0 279 + } else { 280 + let first = parts.first().unwrap(); 274 281 275 - if !pattern.starts_with('*') { 276 - if let Some(part) = parts.first() { 277 - if !path.starts_with(part) { 278 - return false; 279 - } 282 + if !path.starts_with(first) { 283 + return false; 284 + } 280 285 281 - position = part.len(); 286 + first.len() 287 + }; 288 + 289 + let mid_end = parts.len().saturating_sub(1); 290 + 291 + for part in &parts[1..mid_end] { 292 + if part.is_empty() { 293 + continue; 282 294 } 283 - } 284 295 285 - for part in &parts[1..parts.len() - 1] { 286 - if let Some(found_position) = path[position..].find(part) { 287 - position += found_position + part.len(); 296 + if let Some(found) = path[position..].find(part) { 297 + position += found + part.len(); 288 298 } else { 289 299 return false; 290 300 } 291 301 } 292 302 293 303 if !pattern.ends_with('*') { 294 - if let Some(part) = parts.last() { 295 - if !path[position..].ends_with(part) { 296 - return false; 297 - } 304 + let last = parts.last().unwrap(); 305 + 306 + if !path[position..].ends_with(last) { 307 + return false; 298 308 } 299 309 } 300 310