public function _findWebmentionEndpointInHeader($link_header, $targetURL = false) { $endpoint = false; if (preg_match('~<((?:https?://)?[^>]+)>; rel="webmention"~', $link_header, $match)) { $endpoint = $match[1]; } elseif (preg_match('~<((?:https?://)?[^>]+)>; rel="http://webmention.org/?"~', $link_header, $match)) { $endpoint = $match[1]; } if ($endpoint && $targetURL && function_exists('\\mf2\\resolveUrl')) { // Resolve the URL if it's relative $endpoint = \mf2\resolveUrl($targetURL, $endpoint); } return $endpoint; }
/** * @dataProvider testData */ public function testReturnsUrlIfAbsolute($assert, $base, $url, $expected) { $actual = mf2\resolveUrl($base, $url); $this->assertEquals($expected, $actual, $assert); }