mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 20:15:55 +00:00
build_url: also put query parameters and fragment in resulting URL
rewrite_relative_url: simplify handling of relative URLs
This commit is contained in:
@@ -1511,7 +1511,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function build_url($parts) {
|
function build_url($parts) {
|
||||||
return $parts['scheme'] . "://" . $parts['host'] . $parts['path'];
|
$tmp = $parts['scheme'] . "://" . $parts['host'] . $parts['path'];
|
||||||
|
|
||||||
|
if (isset($parts['query'])) $tmp .= '?' . $parts['query'];
|
||||||
|
if (isset($parts['fragment'])) $tmp .= '#' . $parts['fragment'];
|
||||||
|
|
||||||
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1537,23 +1542,16 @@
|
|||||||
} else {
|
} else {
|
||||||
$parts = parse_url($url);
|
$parts = parse_url($url);
|
||||||
|
|
||||||
if (!isset($parts['path'])) {
|
$rel_parts['host'] = $parts['host'];
|
||||||
$parts['path'] = '/';
|
$rel_parts['scheme'] = $parts['scheme'];
|
||||||
}
|
|
||||||
|
|
||||||
$dir = $parts['path'];
|
if (strpos($rel_parts['path'], '/') !== 0)
|
||||||
|
$rel_parts['path'] = '/' . $rel_parts['path'];
|
||||||
|
|
||||||
if (substr($dir, -1) !== '/') {
|
$rel_parts['path'] = str_replace("/./", "/", $rel_parts['path']);
|
||||||
$dir = dirname($parts['path']);
|
$rel_parts['path'] = str_replace("//", "/", $rel_parts['path']);
|
||||||
$dir !== '/' && $dir .= '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
$parts['path'] = $dir . $rel_url;
|
return validate_url(build_url($rel_parts));
|
||||||
|
|
||||||
$parts['path'] = str_replace("/./", "/", $parts['path']);
|
|
||||||
$parts['path'] = str_replace("//", "/", $parts['path']);
|
|
||||||
|
|
||||||
return validate_url(build_url($parts));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user