Skip to content

Commit 1f25ea6

Browse files
coderabbitai[bot]CodeRabbit
andauthored
fix: apply CodeRabbit auto-fixes
Fixed 2 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
1 parent ce75134 commit 1f25ea6

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/http.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ function getPortFromUrl(url: string): string {
5353
return /^\d+$/.test(port) ? port : '';
5454
}
5555

56+
// Helper to bracket IPv6 addresses for use in Host headers with ports
57+
function bracketIPv6(hostname: string): string {
58+
// Already bracketed or not an IPv6 address
59+
if (hostname.startsWith('[') || hostname.indexOf(':') === -1) {
60+
return hostname;
61+
}
62+
// Contains colon(s) but not bracketed - likely bare IPv6
63+
// IPv4 addresses contain at most one colon (not possible without port),
64+
// so multiple colons or any colon in hostname indicates IPv6
65+
return `[${hostname}]`;
66+
}
67+
5668
/**
5769
* A class representing the http client
5870
* @param {Object} [options] Options object. It allows the customization of
@@ -83,7 +95,7 @@ export class HttpClient implements IHttpClient {
8395
const method = data ? 'POST' : 'GET';
8496

8597
const port = getPortFromUrl(rurl);
86-
const host = port ? `${curl.hostname}:${port}` : curl.host || curl.hostname;
98+
const host = port ? `${bracketIPv6(curl.hostname)}:${port}` : curl.host || curl.hostname;
8799
const headers: IHeaders = {
88100
'User-Agent': 'node-soap/' + version,
89101
'Accept': 'text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8',

tsconfig.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@
99
"sourceMap": true,
1010
"declaration": true,
1111
"stripInternal": true,
12-
"skipLibCheck": true
12+
"skipLibCheck": true,
13+
"resolveJsonModule": true,
14+
"esModuleInterop": true,
15+
"types": ["node"],
16+
"strict": false,
17+
"noImplicitAny": false,
18+
"strictNullChecks": false,
19+
"strictFunctionTypes": false,
20+
"strictBindCallApply": false,
21+
"strictPropertyInitialization": false,
22+
"noImplicitThis": false
1323
},
1424
"include": ["src", "./eslint.config.mjs"],
1525
"exclude": ["node_modules"]

0 commit comments

Comments
 (0)