Auto merge of #21308 - paulrouget:jsonerror, r=jdm

Android: Fix JSON error when no arguments are passed

Probably fix #21298

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21308)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-08-01 09:53:11 -04:00 committed by GitHub
commit 890d40dd4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -95,12 +95,14 @@ pub fn init(
) -> Result<(), &'static str> { ) -> Result<(), &'static str> {
resources::set(Box::new(ResourceReader(readfile))); resources::set(Box::new(ResourceReader(readfile)));
let mut args: Vec<String> = serde_json::from_str(&argsline).map_err(|_| { if !argsline.is_empty() {
"Invalid arguments. Servo arguments must be formatted as a JSON array" let mut args: Vec<String> = serde_json::from_str(&argsline).map_err(|_| {
})?; "Invalid arguments. Servo arguments must be formatted as a JSON array"
// opts::from_cmdline_args expects the first argument to be the binary name. })?;
args.insert(0, "servo".to_string()); // opts::from_cmdline_args expects the first argument to be the binary name.
opts::from_cmdline_args(&args); args.insert(0, "servo".to_string());
opts::from_cmdline_args(&args);
}
let embedder_url = embedder_url.as_ref().and_then(|s| { let embedder_url = embedder_url.as_ref().and_then(|s| {
ServoUrl::parse(s).ok() ServoUrl::parse(s).ok()