Skip to content

Commit 125ff11

Browse files
committedOct 11, 2023
Replicated former ENS normalize behaviour for empty strings and update namehash testcases.
1 parent bc115a2 commit 125ff11

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
 

‎src.ts/hash/namehash.ts

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function ensNameSplit(name: string): Array<Uint8Array> {
4444
*/
4545
export function ensNormalize(name: string): string {
4646
try {
47+
if (name.length === 0) { throw new Error("empty label"); }
4748
return ens_normalize(name);
4849
} catch (error: any) {
4950
assertArgument(false, `invalid ENS name (${ error.message })`, "name", name);
@@ -66,6 +67,8 @@ export function isValidName(name: string): name is string {
6667
export function namehash(name: string): string {
6768
assertArgument(typeof(name) === "string", "invalid ENS name; not a string", "name", name);
6869

70+
assertArgument(name.length, `invalid ENS name (empty label)`, "name", name);
71+
6972
let result: string | Uint8Array = Zeros;
7073

7174
const comps = ensNameSplit(name);

‎testcases/namehash.json.gz

31.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.