mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-07 01:03:34 +02:00
Don't use prefix matching if we can help it
This commit is contained in:
@@ -289,10 +289,7 @@ describe('resolveChannelFromHashToken', () => {
|
||||
];
|
||||
|
||||
it('prefers stable key lookup (case-insensitive)', () => {
|
||||
const result = resolveChannelFromHashToken(
|
||||
'abcdef0123456789abcdef0123456789',
|
||||
channels
|
||||
);
|
||||
const result = resolveChannelFromHashToken('abcdef0123456789abcdef0123456789', channels);
|
||||
expect(result?.key).toBe('ABCDEF0123456789ABCDEF0123456789');
|
||||
});
|
||||
|
||||
|
||||
@@ -74,7 +74,9 @@ export function resolveChannelFromHashToken(token: string, channels: Channel[]):
|
||||
if (byKey) return byKey;
|
||||
|
||||
// Backward compatibility for legacy name-based hashes.
|
||||
return channels.find((c) => c.name === normalizedToken || c.name === `#${normalizedToken}`) || null;
|
||||
return (
|
||||
channels.find((c) => c.name === normalizedToken || c.name === `#${normalizedToken}`) || null
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveContactFromHashToken(token: string, contacts: Contact[]): Contact | null {
|
||||
@@ -86,7 +88,9 @@ export function resolveContactFromHashToken(token: string, contacts: Contact[]):
|
||||
if (byKey) return byKey;
|
||||
|
||||
// Backward compatibility for legacy name/prefix-based hashes.
|
||||
return contacts.find((c) => getContactDisplayName(c.name, c.public_key) === normalizedToken) || null;
|
||||
return (
|
||||
contacts.find((c) => getContactDisplayName(c.name, c.public_key) === normalizedToken) || null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user