new redis url parser
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
const parse = (connectionString: string) => {
|
const parse = (connectionString: string) => {
|
||||||
const url = new URL(connectionString);
|
const match = connectionString.match(/redis:\/\/(.+?):(.+?)@(.+?):(.+)/);
|
||||||
|
if (!match) {
|
||||||
|
throw new Error('Invalid connection string');
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
host: url.hostname,
|
host: match[3]!,
|
||||||
port: Number(url.port),
|
port: Number(match[4]),
|
||||||
password: url.password,
|
password: match[2]!,
|
||||||
} as const;
|
} as const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user