mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Only interpret URL as filenames in command-line arguments.
This commit is contained in:
parent
2fea2cd911
commit
447655144d
2 changed files with 7 additions and 23 deletions
|
@ -48,8 +48,9 @@ use servo_util::memory::MemoryProfiler;
|
|||
|
||||
#[cfg(not(test))]
|
||||
use servo_util::opts;
|
||||
|
||||
#[cfg(not(test))]
|
||||
use servo_util::url::parse_url;
|
||||
use url::{Url, UrlParser};
|
||||
|
||||
|
||||
#[cfg(not(test), not(target_os="android"))]
|
||||
|
@ -132,9 +133,12 @@ pub fn run(opts: opts::Opts) {
|
|||
font_cache_task,
|
||||
time_profiler_chan_clone);
|
||||
|
||||
let base_url = Url::from_directory_path(&os::getcwd()).unwrap();
|
||||
let mut url_parser = UrlParser::new();
|
||||
let url_parser = url_parser.base_url(&base_url);
|
||||
// Send the URL command to the constellation.
|
||||
for filename in opts.urls.iter() {
|
||||
let url = parse_url(filename.as_slice(), None);
|
||||
for url in opts.urls.iter() {
|
||||
let url = url_parser.parse(url.as_slice()).ok().expect("URL parsing failed");
|
||||
|
||||
let ConstellationChan(ref chan) = constellation_chan;
|
||||
chan.send(InitLoadUrlMsg(url));
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::os;
|
||||
use rust_url;
|
||||
use rust_url::{Url, UrlParser};
|
||||
|
||||
|
@ -23,25 +22,6 @@ pub fn try_parse_url(str_url: &str, base_url: Option<Url>) -> Result<Url, &'stat
|
|||
Some(ref base) => &*parser.base_url(base),
|
||||
None => &parser,
|
||||
};
|
||||
let str_url = match parser.parse(str_url) {
|
||||
Err(err) => {
|
||||
if base_url.is_none() {
|
||||
// Assume we've been given a file path. If it's absolute just return
|
||||
// it, otherwise make it absolute with the cwd.
|
||||
if str_url.as_slice().starts_with("/") {
|
||||
format!("file://{}", str_url)
|
||||
} else {
|
||||
let mut path = os::getcwd();
|
||||
path.push(str_url);
|
||||
// FIXME (#1094): not the right way to transform a path
|
||||
format!("file://{}", path.display().to_str())
|
||||
}
|
||||
} else {
|
||||
return Err(err)
|
||||
}
|
||||
},
|
||||
Ok(url) => return Ok(url)
|
||||
};
|
||||
parser.parse(str_url.as_slice())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue