mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
fix: correct encode mongodb auth credentials (#10024)
* fix: correct encode mongodb auth credentials when use the special character `@` into mongodb password result in unauthorized because the it has no encoding Closes: #9885 * we need to close connections at the end * fixed js issue * adjust import statement * style: run prettier --------- Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
This commit is contained in:
parent
9460296147
commit
96b7ee44b2
@ -528,7 +528,9 @@ export class MongoDriver implements Driver {
|
||||
const schemaUrlPart = options.type.toLowerCase()
|
||||
const credentialsUrlPart =
|
||||
options.username && options.password
|
||||
? `${options.username}:${options.password}@`
|
||||
? `${encodeURIComponent(options.username)}:${encodeURIComponent(
|
||||
options.password,
|
||||
)}@`
|
||||
: ""
|
||||
|
||||
const portUrlPart =
|
||||
|
||||
24
test/github-issues/9885/issue-9885.ts
Normal file
24
test/github-issues/9885/issue-9885.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { expect } from "chai"
|
||||
import { DataSource } from "../../../src"
|
||||
import {
|
||||
closeTestingConnections,
|
||||
createTestingConnections,
|
||||
} from "../../utils/test-utils"
|
||||
|
||||
describe("github issues > #9885", () => {
|
||||
let dataSources: DataSource[]
|
||||
|
||||
before(async () => {
|
||||
dataSources = await createTestingConnections({
|
||||
entities: [],
|
||||
enabledDrivers: ["mongodb"],
|
||||
})
|
||||
})
|
||||
after(() => closeTestingConnections(dataSources))
|
||||
|
||||
it("should be connected", () => {
|
||||
dataSources.forEach((dataSource) => {
|
||||
expect(dataSource.isInitialized).true
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user