-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Issue description:
The getHashedName function in the tld-parser/src/utils.ts file is marked as async, but it does not contain any asynchronous operations, such as await. The sha256 function looks to be synchronous, and no asynchronous actions look like they are being performed within the function. The async keyword can be removed from the function declaration to avoid confusion.
Affected code:
The issue can be found in the tld-parser/src/utils.ts file on line 66:
export async function getHashedName(name: string): Promise<Buffer> {
const input = NameRecordHeader.HASH_PREFIX + name;
const str = sha256(Buffer.from(input, 'utf8')).slice(2);
return Buffer.from(str, 'hex');
}Proposed change:
Remove the async keyword from the function declaration and update the function signature:
export function getHashedName(name: string): Buffer {
const input = NameRecordHeader.HASH_PREFIX + name;
const str = sha256(Buffer.from(input, 'utf8')).slice(2);
return Buffer.from(str, 'hex');
}Impact:
This change shouldn't affect its functionality, may prevent potential misunderstandings related to the use of the async keyword.
TypeScript is going to complain / warn about the await no longer being needed given the signature changed to Buffer now, so other functions and methods awaiting or using .then() on this function don't need to, will help with code clarity removing await from other methods / functions using this function across the library anyway.