fix(tests): fix tests
This commit is contained in:
@ -52,6 +52,9 @@ export class WrappedSocket {
|
||||
if (prop === 'setProxyInfo') {
|
||||
return target.setProxyInfo.bind(target);
|
||||
}
|
||||
if (prop === 'remoteFamily') {
|
||||
return target.remoteFamily;
|
||||
}
|
||||
|
||||
// For all other properties/methods, delegate to the underlying socket
|
||||
const value = target.socket[prop as keyof plugins.net.Socket];
|
||||
@ -89,6 +92,21 @@ export class WrappedSocket {
|
||||
return !!this.realClientIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address family of the remote IP
|
||||
*/
|
||||
get remoteFamily(): string | undefined {
|
||||
const ip = this.realClientIP || this.socket.remoteAddress;
|
||||
if (!ip) return undefined;
|
||||
|
||||
// Check if it's IPv6
|
||||
if (ip.includes(':')) {
|
||||
return 'IPv6';
|
||||
}
|
||||
// Otherwise assume IPv4
|
||||
return 'IPv4';
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the real client information (called after parsing PROXY protocol)
|
||||
*/
|
||||
|
@ -95,7 +95,8 @@ export class PathMatcher implements IMatcher<IPathMatchResult> {
|
||||
if (normalizedPattern.includes('*') && match.length > paramNames.length + 1) {
|
||||
const wildcardCapture = match[match.length - 1];
|
||||
if (wildcardCapture) {
|
||||
pathRemainder = wildcardCapture;
|
||||
// Ensure pathRemainder includes leading slash if it had one
|
||||
pathRemainder = wildcardCapture.startsWith('/') ? wildcardCapture : '/' + wildcardCapture;
|
||||
pathMatch = normalizedPath.substring(0, normalizedPath.length - wildcardCapture.length);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user