fix(core_node): Fix unix socket URL parsing and handling in CoreRequest

This commit is contained in:
2025-11-16 23:22:58 +00:00
parent f3ba77050a
commit 9f3503704b
4 changed files with 22 additions and 5 deletions

View File

@@ -17,10 +17,22 @@ export abstract class CoreRequest<
/**
* Parses socket path and route from unix socket URL
* Handles both full URLs (http://unix:/path/to/socket:/route) and pre-stripped paths (unix:/path/to/socket:/route)
*/
static parseUnixSocketUrl(url: string): { socketPath: string; path: string } {
// Strip http:// or https:// prefix if present
// This makes the method work with both full URLs and pre-stripped paths
let cleanUrl = url;
if (cleanUrl.startsWith('http://')) {
cleanUrl = cleanUrl.substring('http://'.length);
} else if (cleanUrl.startsWith('https://')) {
cleanUrl = cleanUrl.substring('https://'.length);
}
// Parse the socket path and HTTP path
// Format: unix:/path/to/socket:/route/path
const parseRegex = /(.*):(.*)/;
const result = parseRegex.exec(url);
const result = parseRegex.exec(cleanUrl);
return {
socketPath: result[1],
path: result[2],