| 472 | } |
| 473 | |
| 474 | fn url_paths(&self) -> Result<UrlMatches> { |
| 475 | let mut urls = HashSet::new(); |
| 476 | for url in &self.search.urls { |
| 477 | urls.insert(url.normalized.to_owned()); |
| 478 | } |
| 479 | |
| 480 | if urls.is_empty() { |
| 481 | return Ok(UrlMatches::allow_everything()); |
| 482 | } |
| 483 | |
| 484 | if urls.len() != 1 { |
| 485 | return Ok(UrlMatches::impossible_result()); |
| 486 | } |
| 487 | |
| 488 | match urls.iter().next() { |
| 489 | Some(url) => { |
| 490 | let mut ids = HashSet::new(); |
| 491 | let url = match RepoUrl::parse(url) { |
| 492 | Ok(url) => url, |
| 493 | Err(err) => { |
| 494 | log::error!("search: problem parsing url: {}", err); |
| 495 | return Ok(UrlMatches::impossible_result()); |
| 496 | } |
| 497 | }; |
| 498 | |
| 499 | let id = url.id()?; |
| 500 | ids.insert(id); |
| 501 | |
| 502 | Ok(UrlMatches { |
| 503 | ids, |
| 504 | impossible_result: false, |
| 505 | }) |
| 506 | } |
| 507 | |
| 508 | None => Ok(UrlMatches::impossible_result()), |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | #[cfg(test)] |