fix(core_base/request): Strip unix: prefix when parsing unix socket URLs so socketPath is a clean filesystem path
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartrequest',
|
||||
version: '4.4.1',
|
||||
version: '4.4.2',
|
||||
description: 'A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.'
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ 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)
|
||||
* Returns clean file system path for socketPath (e.g., /var/run/docker.sock)
|
||||
*/
|
||||
static parseUnixSocketUrl(url: string): { socketPath: string; path: string } {
|
||||
// Strip http:// or https:// prefix if present
|
||||
@@ -29,8 +30,13 @@ export abstract class CoreRequest<
|
||||
cleanUrl = cleanUrl.substring('https://'.length);
|
||||
}
|
||||
|
||||
// Strip unix: prefix if present to get clean file system path
|
||||
if (cleanUrl.startsWith('unix:')) {
|
||||
cleanUrl = cleanUrl.substring('unix:'.length);
|
||||
}
|
||||
|
||||
// Parse the socket path and HTTP path
|
||||
// Format: unix:/path/to/socket:/route/path
|
||||
// Format: /path/to/socket:/route/path
|
||||
const parseRegex = /(.*):(.*)/;
|
||||
const result = parseRegex.exec(cleanUrl);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user