fix(generators): Harden mongodb.js to reliably extract database from any connection string#3264
Merged
daffl merged 4 commits intofeathersjs:dovefrom Jan 5, 2024
Merged
fix(generators): Harden mongodb.js to reliably extract database from any connection string#3264daffl merged 4 commits intofeathersjs:dovefrom
daffl merged 4 commits intofeathersjs:dovefrom
Conversation
Member
|
Thank you for putting this PR up (and sorry for the late reply). I wonder if we should make this a helper since we'd want the generated code to be as short as possible. |
Contributor
Author
|
Let me optimize it to be as short as possible |
Contributor
Author
|
it's now just one additional line of code from what it was originally |
daffl
approved these changes
Jan 5, 2024
Member
|
Thank you for updating and sorry for the delay. |
Member
|
Apologies again but I had to revert the merge. I thought the tests were failing because things weren't up to date with latest but the error was actually an invalid regular expression that I wasn't able to fix (see errors in https://github.com/feathersjs/feathers/actions/runs/7427523402/job/20213354620#step:8:3307). You can run all test locally by running |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default connection for mongodb in mongodb.js fails when you try to connect with a connection string that uses mongodb-replicas sets or clusters ... (eg: mongodb://localhost:27017,127.0.0.1:27018/mo-db?replicaSet=rs0) ... This is because
new URL(connection).pathname.substring(1)
fails with an is not a valid URL error .... I propose the following replacement to mongodb.js as it will satisfy all most all formats of connection strings