Skip to content

Commit c55a1fb

Browse files
refactor: remove hostname port extraction, only use Advanced section
- Remove extractPortFromHostname function entirely - Update getPortFromAdvanced to only check profile.Advanced for port - Fallback to default port from database type dropdown if no Advanced port found - Ensure graceful handling when port information is not available Co-authored-by: modelorona <modelorona@users.noreply.github.com>
1 parent 825621d commit c55a1fb

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

frontend/src/components/profile-info-tooltip.tsx

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,6 @@ function isValidProfileId(profileId: string): boolean {
1919
/^[a-zA-Z0-9_-]+$/.test(profileId);
2020
}
2121

22-
// IPv6-safe hostname/port extraction
23-
function extractPortFromHostname(hostname: string): string {
24-
if (!hostname || typeof hostname !== 'string') {
25-
return 'Default';
26-
}
27-
28-
// Handle IPv6 addresses by checking for square brackets
29-
if (hostname.includes('[')) {
30-
const match = hostname.match(/\]:(\d+)$/);
31-
return match ? match[1] : 'Default';
32-
}
33-
34-
const parts = hostname.split(':');
35-
if (parts.length > 1) {
36-
const port = parts[parts.length - 1];
37-
// Check if the last part is numeric (a port)
38-
if (/^\d+$/.test(port)) {
39-
return port;
40-
}
41-
}
42-
return 'Default';
43-
}
4422

4523
function getPortFromAdvanced(profile: LocalLoginProfile): string | null {
4624
const dbType = profile.Type;
@@ -57,14 +35,6 @@ function getPortFromAdvanced(profile: LocalLoginProfile): string | null {
5735
return portObj?.Value || defaultPort;
5836
}
5937

60-
// Check if hostname contains port info
61-
if (profile.Host) {
62-
const extractedPort = extractPortFromHostname(profile.Host);
63-
if (extractedPort !== 'Default') {
64-
return extractedPort;
65-
}
66-
}
67-
6838
return defaultPort;
6939
}
7040

0 commit comments

Comments
 (0)