fix(browser): match Chrome by basename for macOS ps paths
`ps -o comm=` can return a full path; normalize before the image check. Also declare the browser workspace dependency so the macOS app link resolves.
@@ -55,7 +55,10 @@ fn listener_pid(platform: Platform, port: u16) -> Result<u32, BrowserError> {
55
55
}
56
56
57
57
pub(crate) fn is_chrome_image(image_name: &str) -> bool {
58
let lowered = image_name.trim().trim_matches('"').to_ascii_lowercase();
58
// macOS `ps -o comm=` may return a full path; match on the basename.
59
let trimmed = image_name.trim().trim_matches('"');
60
let base = trimmed.rsplit(['/', '\\']).next().unwrap_or(trimmed).trim();
61
let lowered = base.to_ascii_lowercase();
59
62
lowered.starts_with("chrome")
60
63
|| lowered.starts_with("google chrome")
61
64
|| lowered.starts_with("chromium")
@@ -111,7 +114,14 @@ mod tests {
111
114
assert!(is_chrome_image("chrome\n"));
112
115
assert!(is_chrome_image("Google Chrome"));
113
116
assert!(is_chrome_image("Chromium"));
117
assert!(is_chrome_image(
118
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
119
));
120
assert!(is_chrome_image("/usr/bin/chromium"));
114
121
assert!(!is_chrome_image("\"wslrelay.exe\""));
122
assert!(!is_chrome_image(
123
"/Applications/Firefox.app/Contents/MacOS/firefox"
124
));
115
125
assert!(!is_chrome_image(""));
116
126
}
117
127
@@ -55,7 +55,10 @@ fn listener_pid(platform: Platform, port: u16) -> Result<u32, BrowserError> {55
}55
}56
56
57
pub(crate) fn is_chrome_image(image_name: &str) -> bool {57
pub(crate) fn is_chrome_image(image_name: &str) -> bool {58
let lowered = image_name.trim().trim_matches('"').to_ascii_lowercase();58
// macOS `ps -o comm=` may return a full path; match on the basename.59
let trimmed = image_name.trim().trim_matches('"');60
let base = trimmed.rsplit(['/', '\\']).next().unwrap_or(trimmed).trim();61
let lowered = base.to_ascii_lowercase();59
lowered.starts_with("chrome")62
lowered.starts_with("chrome")60
|| lowered.starts_with("google chrome")63
|| lowered.starts_with("google chrome")61
|| lowered.starts_with("chromium")64
|| lowered.starts_with("chromium")@@ -111,7 +114,14 @@ mod tests {111
assert!(is_chrome_image("chrome\n"));114
assert!(is_chrome_image("chrome\n"));112
assert!(is_chrome_image("Google Chrome"));115
assert!(is_chrome_image("Google Chrome"));113
assert!(is_chrome_image("Chromium"));116
assert!(is_chrome_image("Chromium"));117
assert!(is_chrome_image(118
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"119
));120
assert!(is_chrome_image("/usr/bin/chromium"));114
assert!(!is_chrome_image("\"wslrelay.exe\""));121
assert!(!is_chrome_image("\"wslrelay.exe\""));122
assert!(!is_chrome_image(123
"/Applications/Firefox.app/Contents/MacOS/firefox"124
));115
assert!(!is_chrome_image(""));125
assert!(!is_chrome_image(""));116
}126
}117
127