mirror of
https://github.com/YGGverse/gemini-dl.git
synced 2026-03-31 09:05:31 +00:00
resolve relative redirection targets (untested)
This commit is contained in:
parent
f19ab43390
commit
2d5e14f527
1 changed files with 14 additions and 4 deletions
|
|
@ -213,17 +213,27 @@ class Cli
|
||||||
{
|
{
|
||||||
if ($this->redirects <= $this->option->follow)
|
if ($this->redirects <= $this->option->follow)
|
||||||
{
|
{
|
||||||
|
// Build new address
|
||||||
|
$target = new Address(
|
||||||
|
trim($response->getMeta())
|
||||||
|
);
|
||||||
|
|
||||||
|
// Make relative links absolute
|
||||||
|
$target->toAbsolute(
|
||||||
|
$source
|
||||||
|
);
|
||||||
|
|
||||||
// Validate redirection target location
|
// Validate redirection target location
|
||||||
if (filter_var($response->getMeta(), FILTER_VALIDATE_URL)) // @TODO resolve relative locations
|
if (filter_var($target->get(), FILTER_VALIDATE_URL))
|
||||||
{
|
{
|
||||||
// Insert redirection target to the next destination
|
// Insert redirection target to the next destination
|
||||||
if (!$this->putSource($offset + 1, trim($response->getMeta())))
|
if (!$this->putSource($offset + 1, $target->get()))
|
||||||
{
|
{
|
||||||
print(
|
print(
|
||||||
Message::red(
|
Message::red(
|
||||||
sprintf(
|
sprintf(
|
||||||
_("\tdestination could not be updated due to the conditions or it has already been indexed: `%s`"),
|
_("\tdestination could not be updated due to the conditions or it has already been indexed: `%s`"),
|
||||||
$response->getMeta()
|
$target->get()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -235,7 +245,7 @@ class Cli
|
||||||
Message::red(
|
Message::red(
|
||||||
sprintf(
|
sprintf(
|
||||||
_("\tskip invalid redirection URL: `%s`"),
|
_("\tskip invalid redirection URL: `%s`"),
|
||||||
$response->getMeta()
|
$target->get()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue