-
-
Notifications
You must be signed in to change notification settings - Fork 650
Closed
Description
To parse the connection string, we use "new Url(xxx)" but it looks like it urlencodes the parameters : Hence invalidating them when there are special chars.
imagine the password is xx^xx
the connection string can be :
mysql://root:xx^[email protected]/xx?charset=utf8mb4
or
mysql://root:xx%[email protected]/xx?charset=utf8mb4
both usually work in other libs.
it's worth noting that "new Url()" returns in both cases "password: xx%5Exx"
then ofc the connection cant be established because the password is wrong.
Since we use new Url, we should pass the "password" through decodeURIComponent to get it correctly.
IMHO valid parser would be :
const options = {
host: parsedUrl.hostname,
port: parsedUrl.port,
database: parsedUrl.pathname.slice(1),
user: parsedUrl.username,
password: decodeURIComponent(parsedUrl.password)
};
Metadata
Metadata
Assignees
Labels
No labels