Skip to content
Permalink
Browse files

Fix pattern for host names.

  • Loading branch information...
markstory committed Aug 11, 2017
1 parent edcb3dc commit fa8c5d8e990670f62691216811475e0dd9df8572
Showing with 13 additions and 2 deletions.
  1. +2 −2 src/Core/StaticConfigTrait.php
  2. +11 −0 tests/TestCase/Datasource/ConnectionManagerTest.php
@@ -250,11 +250,11 @@ public static function parseDsn($dsn)
}
$pattern = '/^(?P<scheme>[\w\\\\]+):\/\/((?P<user>.*?)(:(?P<password>.*?))?@)?' .
'((?P<host>[.\w\\\\]+)(:(?P<port>\d+))?)?' .
'((?P<host>[.\w-\\\\]+)(:(?P<port>\d+))?)?' .
'(?P<path>\/[^?]*)?(\?(?P<query>.*))?$/';
preg_match($pattern, $dsn, $parsed);
if (empty($parsed)) {
if (!$parsed) {
throw new InvalidArgumentException("The DSN string '{$dsn}' could not be parsed.");
}
foreach ($parsed as $k => $v) {
@@ -281,6 +281,17 @@ public function dsnProvider()
'scheme' => 'mysql',
]
],
'subdomain host' => [
'mysql://my.host-name.com:3306/database',
[
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'host' => 'my.host-name.com',
'database' => 'database',
'port' => 3306,
'scheme' => 'mysql',
]
],
'user & pass' => [
'mysql://root:secret@localhost:3306/database?log=1',
[

0 comments on commit fa8c5d8

Please sign in to comment.
You can’t perform that action at this time.