We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1a640d1 commit 88d40b3Copy full SHA for 88d40b3
src/adapter/utils.ts
@@ -1,19 +1,20 @@
1
import {existsSync, readFileSync} from "node:fs";
2
+import {urlToHttpOptions} from "node:url";
3
import type * as Models from "../models";
4
5
export function isTcpPath(path: string): boolean {
6
// tcp path must be:
7
// tcp://<host>:<port>
- const regex = /^(?:tcp:\/\/)[\w.-]+[:][\d]+$/gm;
8
+ const regex = /^(?:tcp:\/\/)\S+?[:]\d+$/gm;
9
return regex.test(path);
10
}
11
12
export function parseTcpPath(path: string): {host: string; port: number} {
13
// built-in extra validation
- const info = new URL(path);
14
+ const info = urlToHttpOptions(new URL(path));
15
16
return {
- host: info.hostname,
17
+ host: String(info.hostname),
18
port: Number(info.port),
19
};
20
0 commit comments