Skip to content

Commit ca149da

Browse files
runningcodeclaude
andcommitted
Simplify extract_provider_name with rsplit iterator
Use rsplit iterator instead of Vec collection for cleaner code 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cd97c5d commit ca149da

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/utils/vcs.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,10 @@ impl VcsUrl {
208208
}
209209

210210
fn extract_provider_name(host: &str) -> String {
211-
let trimmed_host = host.trim_end_matches('.');
212-
213-
// Split by dots and take the second-to-last part if there are at least 2 parts
214-
let parts: Vec<&str> = trimmed_host.split('.').collect();
215-
if parts.len() >= 2 {
216-
parts[parts.len() - 2].to_owned()
217-
} else {
218-
trimmed_host.to_owned()
219-
}
211+
let trimmed = host.trim_end_matches('.');
212+
let mut iter = trimmed.rsplit('.');
213+
iter.next(); // skip TLD
214+
iter.next().unwrap_or(trimmed).to_owned()
220215
}
221216

222217
fn is_matching_url(a: &str, b: &str) -> bool {

0 commit comments

Comments
 (0)