Skip to content

Commit f46d575

Browse files
committed
Allow any protocol, or no protocol at all.
1 parent 17c6b1d commit f46d575

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

machines/create-manager.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,14 @@ module.exports = {
211211
//
212212
// Remember: connection string takes priority over `meta` in the event of a conflict.
213213
try {
214-
var parsedConnectionStr = Url.parse(inputs.connectionString);
215-
216-
// Validate that a protocol was found before other pieces
217-
// (otherwise other parsed info will be very weird and wrong)
218-
if (!parsedConnectionStr.protocol || parsedConnectionStr.protocol !== 'mysql:') {
219-
throw new Error('Protocol (i.e. `mysql://`) is required in connection string.');
214+
var urlToParse = inputs.connectionString;
215+
// We don't actually care about the protocol, but `url.parse()` returns funky results
216+
// if the argument doesn't have one. So we'll add one if necessary.
217+
// See https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax
218+
if (!urlToParse.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//)) {
219+
urlToParse = 'mysql://' + urlToParse;
220220
}
221+
var parsedConnectionStr = Url.parse(urlToParse);
221222

222223
// Parse port & host
223224
var DEFAULT_HOST = 'localhost';

0 commit comments

Comments
 (0)