mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
Fix URL relativization so that links on Wikipedia work
This commit is contained in:
parent
f3ad95fa01
commit
1aa8d6437d
1 changed files with 6 additions and 3 deletions
|
@ -30,10 +30,13 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
||||||
} else {
|
} else {
|
||||||
let current_url = current_url.get();
|
let current_url = current_url.get();
|
||||||
debug!("make_url: current_url: %?", current_url);
|
debug!("make_url: current_url: %?", current_url);
|
||||||
if current_url.path.is_empty() || current_url.path.ends_with("/") {
|
if str_url.starts_with("//") {
|
||||||
current_url.scheme + "://" + current_url.host + "/" + str_url
|
|
||||||
} else if str_url.starts_with("//") {
|
|
||||||
current_url.scheme + ":" + str_url
|
current_url.scheme + ":" + str_url
|
||||||
|
} else if current_url.path.is_empty() ||
|
||||||
|
str_url.starts_with("/") {
|
||||||
|
current_url.scheme + "://" +
|
||||||
|
current_url.host + "/" +
|
||||||
|
str_url.trim_left_chars([ '/' ])
|
||||||
} else {
|
} else {
|
||||||
let mut path = ~[];
|
let mut path = ~[];
|
||||||
for str::each_split_char(current_url.path, '/') |p| {
|
for str::each_split_char(current_url.path, '/') |p| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue