mirror of
https://github.com/denoland/deno.git
synced 2025-10-03 23:54:37 +00:00
fix(cli/flags): don't panic on invalid location scheme (#9202)
This commit is contained in:
parent
25830a1067
commit
452df2f23a
1 changed files with 14 additions and 3 deletions
17
cli/flags.rs
17
cli/flags.rs
|
@ -941,7 +941,7 @@ The executable name is inferred by default:
|
||||||
and the path has no parent, take the file name of the parent path. Otherwise
|
and the path has no parent, take the file name of the parent path. Otherwise
|
||||||
settle with the generic name.
|
settle with the generic name.
|
||||||
- If the resulting name has an '@...' suffix, strip it.
|
- If the resulting name has an '@...' suffix, strip it.
|
||||||
|
|
||||||
This commands supports cross-compiling to different target architectures using `--target` flag.
|
This commands supports cross-compiling to different target architectures using `--target` flag.
|
||||||
On the first invocation with deno will download proper binary and cache it in $DENO_DIR. The
|
On the first invocation with deno will download proper binary and cache it in $DENO_DIR. The
|
||||||
aarch64-apple-darwin target is not supported in canary.
|
aarch64-apple-darwin target is not supported in canary.
|
||||||
|
@ -1475,11 +1475,11 @@ fn location_arg<'a, 'b>() -> Arg<'a, 'b> {
|
||||||
return Err("Failed to parse URL".to_string());
|
return Err("Failed to parse URL".to_string());
|
||||||
}
|
}
|
||||||
let mut url = url.unwrap();
|
let mut url = url.unwrap();
|
||||||
url.set_username("").unwrap();
|
|
||||||
url.set_password(None).unwrap();
|
|
||||||
if !["http", "https"].contains(&url.scheme()) {
|
if !["http", "https"].contains(&url.scheme()) {
|
||||||
return Err("Expected protocol \"http\" or \"https\"".to_string());
|
return Err("Expected protocol \"http\" or \"https\"".to_string());
|
||||||
}
|
}
|
||||||
|
url.set_username("").unwrap();
|
||||||
|
url.set_password(None).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.help("Value of 'globalThis.location' used by some web APIs")
|
.help("Value of 'globalThis.location' used by some web APIs")
|
||||||
|
@ -3411,4 +3411,15 @@ mod tests {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn location_with_bad_scheme() {
|
||||||
|
#[rustfmt::skip]
|
||||||
|
let r = flags_from_vec(svec!["deno", "run", "--location", "foo:", "mod.ts"]);
|
||||||
|
assert!(r.is_err());
|
||||||
|
assert!(r
|
||||||
|
.unwrap_err()
|
||||||
|
.to_string()
|
||||||
|
.contains("Expected protocol \"http\" or \"https\""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue