Fix 'make_url' to handle absolute paths properly, allows servo command line to handle absolute paths.

This commit is contained in:
Josh Aas 2013-04-11 21:08:09 -05:00
parent 4b1ab13aef
commit ca84c0bdc3

View file

@ -20,9 +20,13 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
let mut schm = url::get_scheme(str_url);
let str_url = if result::is_err(&schm) {
if current_url.is_none() {
// If all we have is a filename, assume it's a local relative file
// and build an absolute path with the cwd
~"file://" + os::getcwd().push(str_url).to_str()
// 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[0] == "/"[0] {
~"file://" + str_url
} else {
~"file://" + os::getcwd().push(str_url).to_str()
}
} else {
let current_url = current_url.get();
debug!("make_url: current_url: %?", current_url);