diff --git a/changelog.md b/changelog.md index 80e1061..b8c5a40 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-11-16 - 4.4.2 - fix(core_base/request) +Strip 'unix:' prefix when parsing unix socket URLs so socketPath is a clean filesystem path + +- CoreRequest.parseUnixSocketUrl now removes a leading 'unix:' prefix and returns socketPath as a filesystem path (e.g., /var/run/docker.sock) +- Updated tests for Bun, Deno and Node to expect socketPath without the 'unix:' prefix +- Adjusted comments/documentation in core_base/request.ts to clarify returned socketPath format + ## 2025-11-16 - 4.4.1 - fix(core_node) Fix unix socket URL parsing and handling in CoreRequest diff --git a/test/test.unixsocket.bun.ts b/test/test.unixsocket.bun.ts index abe4793..bf5b001 100644 --- a/test/test.unixsocket.bun.ts +++ b/test/test.unixsocket.bun.ts @@ -25,7 +25,7 @@ tap.test('bun: should detect unix socket URLs correctly', async () => { tap.test('bun: should parse unix socket URLs correctly', async () => { const result = CoreRequest.parseUnixSocketUrl('unix:/var/run/docker.sock:/v1.24/version'); - expect(result.socketPath).toEqual('unix:/var/run/docker.sock'); + expect(result.socketPath).toEqual('/var/run/docker.sock'); expect(result.path).toEqual('/v1.24/version'); }); diff --git a/test/test.unixsocket.deno.ts b/test/test.unixsocket.deno.ts index 23f6d51..b8d9721 100644 --- a/test/test.unixsocket.deno.ts +++ b/test/test.unixsocket.deno.ts @@ -25,7 +25,7 @@ tap.test('deno: should detect unix socket URLs correctly', async () => { tap.test('deno: should parse unix socket URLs correctly', async () => { const result = CoreRequest.parseUnixSocketUrl('unix:/var/run/docker.sock:/v1.24/version'); - expect(result.socketPath).toEqual('unix:/var/run/docker.sock'); + expect(result.socketPath).toEqual('/var/run/docker.sock'); expect(result.path).toEqual('/v1.24/version'); }); diff --git a/test/test.unixsocket.node.ts b/test/test.unixsocket.node.ts index bc2eee0..6965f9c 100644 --- a/test/test.unixsocket.node.ts +++ b/test/test.unixsocket.node.ts @@ -26,7 +26,7 @@ tap.test('node: should detect unix socket URLs correctly', async () => { tap.test('node: should parse unix socket URLs correctly', async () => { const result = CoreRequest.parseUnixSocketUrl('unix:/var/run/docker.sock:/v1.24/version'); - expect(result.socketPath).toEqual('unix:/var/run/docker.sock'); + expect(result.socketPath).toEqual('/var/run/docker.sock'); expect(result.path).toEqual('/v1.24/version'); }); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 5a91150..13674bf 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -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.' } diff --git a/ts/core_base/request.ts b/ts/core_base/request.ts index d375a0d..1ccd8ec 100644 --- a/ts/core_base/request.ts +++ b/ts/core_base/request.ts @@ -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 {