diff --git a/src/library/sphinxql.php b/src/library/sphinxql.php index 709d34b..65de5ed 100644 --- a/src/library/sphinxql.php +++ b/src/library/sphinxql.php @@ -50,17 +50,30 @@ class SphinxQL { private static function _match(string $keyword) : string { $keyword = trim($keyword); - $keyword = preg_replace('/[\:]+/', ':', $keyword); + + // Parse url request + $peerAddress = $keyword; + $peerRemoteScheme = $keyword; + $peerRemoteHost = $keyword; + $peerRemotePort = $keyword; + + if ($url = Yggverse\Parser\Url::parse($keyword)) { + + $peerAddress = $url->host->name ? $url->host->name : $keyword; + $peerRemoteScheme = $url->host->scheme ? $url->host->scheme : $keyword; + $peerRemoteHost = $url->host->name ? $url->host->name : $keyword; + $peerRemotePort = $url->host->port ? $url->host->port : $keyword; + } return sprintf( '@peerAddress "%s" | @peerKey "%s" | @peerCoordinatePort "%s" | @peerCoordinateRoute "%s" | @peerRemoteScheme "%s" | @peerRemoteHost "%s" | @peerRemotePort "%s"', - preg_replace('/[^A-z0-9\:]/', '', $keyword), - preg_replace('/[^A-z0-9]/', '', $keyword), - preg_replace('/[^\d]/', '', $keyword), - preg_replace('/[^\d]/', '', $keyword), - preg_replace('/[^A-z]/', '', $keyword), - preg_replace('/[^A-z0-9\.\:]/', '', $keyword), - preg_replace('/[^\d]/', '', $keyword), + preg_replace('/[^A-z0-9\:\[\]]/', '', $peerAddress), + preg_replace('/[^A-z0-9]/', '', $keyword), + preg_replace('/[^\d]/', '', $keyword), + preg_replace('/[^\d]/', '', $keyword), + preg_replace('/[^A-z]/', '', $peerRemoteScheme), + preg_replace('/[^A-z0-9\.\:\[\]]/', '', $peerRemoteHost), + preg_replace('/[^\d]/', '', $peerRemotePort), ); } } diff --git a/src/public/search.php b/src/public/search.php index 3b7d23d..70bacc9 100644 --- a/src/public/search.php +++ b/src/public/search.php @@ -146,7 +146,9 @@ $results = $sphinx->searchPeers($requestQuery,