Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1305b92ebe | |||
| 8b52ca1021 | |||
| e14800f077 | |||
| 9f3503704b |
14
changelog.md
14
changelog.md
@@ -1,5 +1,19 @@
|
|||||||
# Changelog
|
# 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
|
||||||
|
|
||||||
|
- CoreRequest.parseUnixSocketUrl now strips http:// and https:// prefixes so it correctly parses both full URLs (e.g. http://unix:/path/to/socket:/route) and already-stripped unix: paths.
|
||||||
|
- Node.js CoreRequest now passes the original request URL to parseUnixSocketUrl instead of options.path, preventing incorrect socketPath/path extraction.
|
||||||
|
- Fixes connection failures when using unix socket URLs (for example when targeting Docker via http://unix:/var/run/docker.sock:/v1.24/...).
|
||||||
|
|
||||||
## 2025-11-16 - 4.4.0 - feat(core)
|
## 2025-11-16 - 4.4.0 - feat(core)
|
||||||
Add Bun and Deno runtime support, unify core loader, unix-socket support and cross-runtime streaming/tests
|
Add Bun and Deno runtime support, unify core loader, unix-socket support and cross-runtime streaming/tests
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartrequest",
|
"name": "@push.rocks/smartrequest",
|
||||||
"version": "4.4.0",
|
"version": "4.4.2",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.",
|
"description": "A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ tap.test('bun: should detect unix socket URLs correctly', async () => {
|
|||||||
|
|
||||||
tap.test('bun: should parse 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');
|
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');
|
expect(result.path).toEqual('/v1.24/version');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ tap.test('deno: should detect unix socket URLs correctly', async () => {
|
|||||||
|
|
||||||
tap.test('deno: should parse 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');
|
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');
|
expect(result.path).toEqual('/v1.24/version');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ tap.test('node: should detect unix socket URLs correctly', async () => {
|
|||||||
|
|
||||||
tap.test('node: should parse 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');
|
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');
|
expect(result.path).toEqual('/v1.24/version');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartrequest',
|
name: '@push.rocks/smartrequest',
|
||||||
version: '4.4.0',
|
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.'
|
description: 'A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,28 @@ export abstract class CoreRequest<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses socket path and route from unix socket URL
|
* 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 } {
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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: /path/to/socket:/route/path
|
||||||
const parseRegex = /(.*):(.*)/;
|
const parseRegex = /(.*):(.*)/;
|
||||||
const result = parseRegex.exec(url);
|
const result = parseRegex.exec(cleanUrl);
|
||||||
return {
|
return {
|
||||||
socketPath: result[1],
|
socketPath: result[1],
|
||||||
path: result[2],
|
path: result[2],
|
||||||
|
|||||||
@@ -86,9 +86,7 @@ export class CoreRequest extends AbstractCoreRequest<
|
|||||||
|
|
||||||
// Handle unix socket URLs
|
// Handle unix socket URLs
|
||||||
if (CoreRequest.isUnixSocket(this.url)) {
|
if (CoreRequest.isUnixSocket(this.url)) {
|
||||||
const { socketPath, path } = CoreRequest.parseUnixSocketUrl(
|
const { socketPath, path } = CoreRequest.parseUnixSocketUrl(this.url);
|
||||||
this.options.path,
|
|
||||||
);
|
|
||||||
this.options.socketPath = socketPath;
|
this.options.socketPath = socketPath;
|
||||||
this.options.path = path;
|
this.options.path = path;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user