fix: preserve chrome-extension:// and chrome:// URL schemes in CLI (#410)

The CLI's URL normalization was auto-prepending https:// to any URL
whose scheme wasn't in the allowlist (http, https, about, data, file).
This caused chrome-extension:// URLs to become
https://chrome-extension//... which fails with ERR_NAME_NOT_RESOLVED,
preventing navigation to extension pages (popup, side panel, options).

Add chrome-extension:// and chrome:// to the open command's scheme
allowlist, and update the record start/restart commands to preserve
any URL that already contains :// instead of only checking for http.

Fixes #409
This commit is contained in:
Ryan Siddle
2026-02-26 11:30:02 -06:00
committed by GitHub
parent b59dc4c82c
commit b455a58aa2
+40 -4
View File
@@ -104,6 +104,8 @@ pub fn parse_command(args: &[String], flags: &Flags) -> Result<Value, ParseError
|| url_lower.starts_with("about:")
|| url_lower.starts_with("data:")
|| url_lower.starts_with("file:")
|| url_lower.starts_with("chrome-extension://")
|| url_lower.starts_with("chrome://")
{
url.to_string()
} else {
@@ -1017,8 +1019,8 @@ pub fn parse_command(args: &[String], flags: &Flags) -> Result<Value, ParseError
let url = rest.get(2);
let mut cmd = json!({ "id": id, "action": "recording_start", "path": path });
if let Some(u) = url {
// Add https:// prefix if needed
let url_str = if u.starts_with("http") {
// Add https:// prefix if needed (preserve special schemes)
let url_str = if u.starts_with("http") || u.contains("://") {
u.to_string()
} else {
format!("https://{}", u)
@@ -1037,8 +1039,8 @@ pub fn parse_command(args: &[String], flags: &Flags) -> Result<Value, ParseError
let url = rest.get(2);
let mut cmd = json!({ "id": id, "action": "recording_restart", "path": path });
if let Some(u) = url {
// Add https:// prefix if needed
let url_str = if u.starts_with("http") {
// Add https:// prefix if needed (preserve special schemes)
let url_str = if u.starts_with("http") || u.contains("://") {
u.to_string()
} else {
format!("https://{}", u)
@@ -2364,6 +2366,28 @@ mod tests {
assert!(msg.contains("Invalid JSON for --headers"));
}
#[test]
fn test_navigate_chrome_extension_url() {
let cmd = parse_command(
&args("open chrome-extension://abcdefghijklmnop/popup.html"),
&default_flags(),
)
.unwrap();
assert_eq!(cmd["action"], "navigate");
assert_eq!(
cmd["url"],
"chrome-extension://abcdefghijklmnop/popup.html"
);
}
#[test]
fn test_navigate_chrome_url() {
let cmd =
parse_command(&args("open chrome://extensions"), &default_flags()).unwrap();
assert_eq!(cmd["action"], "navigate");
assert_eq!(cmd["url"], "chrome://extensions");
}
// === Set Headers Tests ===
#[test]
@@ -2706,6 +2730,18 @@ mod tests {
assert_eq!(cmd["url"], "https://example.com");
}
#[test]
fn test_record_start_with_chrome_extension_url() {
let cmd = parse_command(
&args("record start demo.webm chrome-extension://abcdef/popup.html"),
&default_flags(),
)
.unwrap();
assert_eq!(cmd["action"], "recording_start");
assert_eq!(cmd["path"], "demo.webm");
assert_eq!(cmd["url"], "chrome-extension://abcdef/popup.html");
}
#[test]
fn test_record_start_missing_path() {
let result = parse_command(&args("record start"), &default_flags());