diff --git a/src/servo-gfx/util/url.rs b/src/servo-gfx/util/url.rs index e59ce197b82..e12ad9761cf 100644 --- a/src/servo-gfx/util/url.rs +++ b/src/servo-gfx/util/url.rs @@ -20,9 +20,13 @@ pub fn make_url(str_url: ~str, current_url: Option) -> 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.starts_with("/") { + ~"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);