Skip to content

Commit

Permalink
Replicated former ENS normalize behaviour for empty strings and updat…
Browse files Browse the repository at this point in the history
…e namehash testcases.
  • Loading branch information
ricmoo committed Oct 11, 2023
1 parent bc115a2 commit 125ff11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src.ts/hash/namehash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function ensNameSplit(name: string): Array<Uint8Array> {
*/
export function ensNormalize(name: string): string {
try {
if (name.length === 0) { throw new Error("empty label"); }
return ens_normalize(name);
} catch (error: any) {
assertArgument(false, `invalid ENS name (${ error.message })`, "name", name);
Expand All @@ -66,6 +67,8 @@ export function isValidName(name: string): name is string {
export function namehash(name: string): string {
assertArgument(typeof(name) === "string", "invalid ENS name; not a string", "name", name);

assertArgument(name.length, `invalid ENS name (empty label)`, "name", name);

let result: string | Uint8Array = Zeros;

const comps = ensNameSplit(name);
Expand Down
Binary file modified testcases/namehash.json.gz
Binary file not shown.

0 comments on commit 125ff11

Please sign in to comment.