-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TOOL-3009] Dashboard: Support all valid domains as ENS name and not …
…just .eth
- Loading branch information
Showing
19 changed files
with
173 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
"thirdweb": patch | ||
--- | ||
|
||
Add `isValidENSName` utility function for checking if a string is a valid ENS name. It does not check if the name is actually registered, it only checks if the string is in a valid format. | ||
|
||
```ts | ||
import { isValidENSName } from "thirdweb/utils"; | ||
|
||
isValidENSName("thirdweb.eth"); // true | ||
isValidENSName("foo.bar.com"); // true | ||
isValidENSName("foo"); // false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { isValidENSName } from "./isValidENSName.js"; | ||
|
||
describe("isValidENSName", () => { | ||
it("should return true for a valid ENS name", () => { | ||
expect(isValidENSName("thirdweb.eth")).toBe(true); | ||
expect(isValidENSName("deployer.thirdweb.eth")).toBe(true); | ||
expect(isValidENSName("x.eth")).toBe(true); | ||
expect(isValidENSName("foo.bar.com")).toBe(true); | ||
expect(isValidENSName("foo.com")).toBe(true); | ||
expect(isValidENSName("somename.xyz")).toBe(true); | ||
}); | ||
|
||
it("should return false for an invalid ENS name", () => { | ||
// No TLD | ||
expect(isValidENSName("")).toBe(false); | ||
expect(isValidENSName("foo")).toBe(false); | ||
|
||
// parts with length < 2 | ||
expect(isValidENSName(".eth")).toBe(false); | ||
expect(isValidENSName("thirdweb.eth.")).toBe(false); | ||
|
||
// numeric TLD | ||
expect(isValidENSName("foo.123")).toBe(false); | ||
|
||
// whitespace in parts | ||
expect(isValidENSName("foo .com")).toBe(false); | ||
expect(isValidENSName("foo. com")).toBe(false); | ||
|
||
// full-width characters | ||
expect(isValidENSName("foo.bar.com")).toBe(false); | ||
|
||
// wildcard characters | ||
expect(isValidENSName("foo*bar.com")).toBe(false); | ||
|
||
// starts with a hyphen | ||
expect(isValidENSName("-foo.bar.com")).toBe(false); | ||
// ends with a hyphen | ||
expect(isValidENSName("foo.bar.com-")).toBe(false); | ||
|
||
// underscore | ||
expect(isValidENSName("foo_bar.com")).toBe(false); | ||
}); | ||
}); |
Oops, something went wrong.