From ca84c0bdc338580348d988c8a0e1892b41a90087 Mon Sep 17 00:00:00 2001 From: Josh Aas Date: Thu, 11 Apr 2013 21:08:09 -0500 Subject: [PATCH 1/2] Fix 'make_url' to handle absolute paths properly, allows servo command line to handle absolute paths. --- src/servo-gfx/util/url.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/servo-gfx/util/url.rs b/src/servo-gfx/util/url.rs index e59ce197b82..99ff6178458 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[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); From 7d81db6e29483c0d4dc56169f3983c538830f51f Mon Sep 17 00:00:00 2001 From: Josh Aas Date: Thu, 11 Apr 2013 21:38:17 -0500 Subject: [PATCH 2/2] Fix 'make_url' to handle absolute paths properly, allows servo command line to handle absolute paths. --- src/servo-gfx/util/url.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servo-gfx/util/url.rs b/src/servo-gfx/util/url.rs index 99ff6178458..e12ad9761cf 100644 --- a/src/servo-gfx/util/url.rs +++ b/src/servo-gfx/util/url.rs @@ -22,7 +22,7 @@ pub fn make_url(str_url: ~str, current_url: Option) -> Url { if current_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[0] == "/"[0] { + if str_url.starts_with("/") { ~"file://" + str_url } else { ~"file://" + os::getcwd().push(str_url).to_str()