Last active
December 27, 2015 17:09
-
-
Save auramo/7359846 to your computer and use it in GitHub Desktop.
MONGOHQ_URL regex (Scala) which works with username containing dashes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val regex = """mongodb://(\w+):([\w|-]+)@([\w|\.]+):(\d+)/(\w+)""".r | |
url match { | |
case Some(regex(u, p, host, port, dbName)) => | |
ConnectionParams(host, port.toInt, dbName, u, p) | |
case None => { | |
ConnectionParams("127.0.0.1", 27017, "mylocaldb") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment