Skip to content

Commit

Permalink
Fix template: MongoDB database name parsing
Browse files Browse the repository at this point in the history
From the feathers discord:

The current parsing method fails the following MongoDB connection string:
```
mongodb://user:P%40ss@localhost:27017/databaseName?authSource=admin
```

Where it parses `databaseName?authSource=admin` as the database name instead of just `databaseName`.

The following change should parse all database connection strings correctly.
  • Loading branch information
nicholaswhitney authored Nov 3, 2022
1 parent ec94421 commit c78a8e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/cli/src/connection/templates/mongodb.tpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ declare module './declarations' {
export const mongodb = (app: Application) => {
const connection = app.get('mongodb') as string
const database = connection.substring(connection.lastIndexOf('/') + 1)
const database = new URL("mongodb://localhost").pathname.substring(1)
const mongoClient = MongoClient.connect(connection)
.then(client => client.db(database))
Expand Down

0 comments on commit c78a8e7

Please # to comment.