BlueGit

ict rusty-teams

fix(browser): read the Chromium major from fork version lines

Helium prints "Helium 0.21.3.1 (Chromium 157.0.8103.78)", so the first
dotted word gave a Chrome/0 user agent. Take the highest major instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Michael Wallner · pushed by metis

Authored 2026-11-15 · 2 weeks ago

Hash
9ab35da3eab306a46a2c8763c95b01939d1a7a1f
Parent
0e3132f8
1 file changed +11 −7
crates/browser/src/launch.rs +11 −7
@@ -76,14 +76,14 @@ pub(crate) fn major_from_directory_names<'a>(names: impl Iterator<Item = &'a str
76 76 .max()
77 77 }
78 78
79 /// The Chromium major from `--version`. Forks print their own version first, as in
80 /// "Helium 0.21.3.1 (Chromium 157.0.8103.78)", so the highest major wins.
79 81 pub(crate) fn major_from_version_output(output: &str) -> Option<u32> {
80 output.split_whitespace().find_map(|word| {
81 word.split('.')
82 .next()?
83 .parse::<u32>()
84 .ok()
85 .filter(|_| word.contains('.'))
86 })
82 output
83 .split(|character: char| character.is_whitespace() || character == '(' || character == ')')
84 .filter(|word| word.contains('.'))
85 .filter_map(|word| word.split('.').next()?.parse::<u32>().ok())
86 .max()
87 87 }
88 88
89 89 const FALLBACK_MAJOR: u32 = 150;
@@ -280,6 +280,10 @@ mod tests {
280 280 major_from_version_output("Chromium 131.0.6778.85 snap"),
281 281 Some(131)
282 282 );
283 assert_eq!(
284 major_from_version_output("Helium 0.21.3.1 (Chromium 157.0.8103.78)\n"),
285 Some(157)
286 );
283 287 assert_eq!(major_from_version_output("nothing"), None);
284 288 }
285 289
@@ -76,14 +76,14 @@ pub(crate) fn major_from_directory_names<'a>(names: impl Iterator<Item = &'a str
76 .max()
76 .max()
77}
77}
78
78
79/// The Chromium major from `--version`. Forks print their own version first, as in
80/// "Helium 0.21.3.1 (Chromium 157.0.8103.78)", so the highest major wins.
79pub(crate) fn major_from_version_output(output: &str) -> Option<u32> {
81pub(crate) fn major_from_version_output(output: &str) -> Option<u32> {
80 output.split_whitespace().find_map(|word| {
82 output
81 word.split('.')
83 .split(|character: char| character.is_whitespace() || character == '(' || character == ')')
82 .next()?
84 .filter(|word| word.contains('.'))
83 .parse::<u32>()
85 .filter_map(|word| word.split('.').next()?.parse::<u32>().ok())
84 .ok()
86 .max()
85 .filter(|_| word.contains('.'))
86 })
87}
87}
88
88
89const FALLBACK_MAJOR: u32 = 150;
89const FALLBACK_MAJOR: u32 = 150;
@@ -280,6 +280,10 @@ mod tests {
280 major_from_version_output("Chromium 131.0.6778.85 snap"),
280 major_from_version_output("Chromium 131.0.6778.85 snap"),
281 Some(131)
281 Some(131)
282 );
282 );
283 assert_eq!(
284 major_from_version_output("Helium 0.21.3.1 (Chromium 157.0.8103.78)\n"),
285 Some(157)
286 );
283 assert_eq!(major_from_version_output("nothing"), None);
287 assert_eq!(major_from_version_output("nothing"), None);
284 }
288 }
285
289