mirror of
https://github.com/YGGverse/gemini-php.git
synced 2026-03-31 17:05:29 +00:00
add Body::findLinks method
This commit is contained in:
parent
e3f4786f9e
commit
008d191d3c
2 changed files with 32 additions and 0 deletions
|
|
@ -83,4 +83,26 @@ class Body
|
|||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
public function findLinks(string $protocol = 'gemini'): array
|
||||
{
|
||||
$matches = [];
|
||||
|
||||
foreach ($this->_lines as $line)
|
||||
{
|
||||
if (preg_match('/' . $protocol . ':\/\/(.*)[\s\S\'"]*/', trim($line), $match))
|
||||
{
|
||||
$matches[] =
|
||||
sprintf(
|
||||
'%s://%s',
|
||||
$protocol,
|
||||
trim(
|
||||
$match[1]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $matches;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue