Skip to content

Commit

Permalink
fix: enforce lowecase valid hostname for space domain (#1060)
Browse files Browse the repository at this point in the history
* fix: enforce lowecase valid hostname for space domain

* add domain example

* v0.12.14

---------

Co-authored-by: ChaituVR <yourchaitu@gmail.com>
  • Loading branch information
wa0x6e and ChaituVR authored Sep 24, 2024
1 parent d6f0fad commit 2c9a067
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snapshot-labs/snapshot.js",
"version": "0.12.13",
"version": "0.12.14",
"repository": "snapshot-labs/snapshot.js",
"license": "MIT",
"main": "dist/snapshot.cjs.js",
Expand Down
4 changes: 4 additions & 0 deletions src/schemas/space.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
},
"domain": {
"type": "string",
"allOf": [
{ "format": "hostname" },
{ "format": "lowercase" }
],
"title": "domain",
"maxLength": 64
},
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ ajv.addFormat('long', {
validate: () => true
});

ajv.addFormat('lowercase', {
validate: (value: string) => value === value.toLowerCase()
});

ajv.addFormat('ethValue', {
validate: (value: string) => {
if (!value.match(/^([0-9]|[1-9][0-9]+)(\.[0-9]+)?$/)) return false;
Expand Down
1 change: 1 addition & 0 deletions test/examples/space.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"network": "1",
"plugins": {},
"twitter": "lootproject",
"domain": "vote.lootproject.abc",
"strategies": [
{
"name": "erc721",
Expand Down

0 comments on commit 2c9a067

Please sign in to comment.