Skip to content

Commit

Permalink
Fix URL parsing for php 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
voronkovich committed Mar 3, 2023
1 parent 62fdf0a commit f164395
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/DSNConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function configure(PHPMailer $mailer, $dsn)
*/
private function parseDSN($dsn)
{
$config = parse_url($dsn);
$config = $this->parseUrl($dsn);

if (false === $config || !isset($config['scheme']) || !isset($config['host'])) {
throw new Exception(
Expand Down Expand Up @@ -218,4 +218,25 @@ private function configureOptions(PHPMailer $mailer, $options)
}
}
}

/**
* Parse URL.
*
* @param string $url URL
*
* @return array Result
*/
private function parseUrl($url)
{
if (\PHP_VERSION_ID >= 50600 || false === strpos($url, '?')) {
return parse_url($url);
}

$chunks = explode('?', $url);

$result = parse_url($chunks[0]);
$result['query'] = $chunks[1];

return $result;
}
}

0 comments on commit f164395

Please sign in to comment.