Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a610145

Browse files
committed
fix regex inside frontend
1 parent 63c60d8 commit a610145

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

site/src/utils/formUtils.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,10 @@ describe("form util functions", () => {
193193
const validate = () => nameSchema.validateSync("test 3");
194194
expect(validate).toThrow();
195195
});
196+
197+
it("allows '3-test-' to be used as a name", () => {
198+
const validate = () => nameSchema.validateSync("3-test-");
199+
expect(validate).not.toThrow();
200+
});
196201
});
197202
});

site/src/utils/formUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const onChangeTrimmed =
112112
// REMARK: Keep these consts in sync with coderd/httpapi/httpapi.go
113113
const maxLenName = 32;
114114
const displayNameMaxLength = 64;
115-
const usernameRE = /^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$/;
115+
const usernameRE = /^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*-?$/;
116116
const displayNameRE = /^[^\s](.*[^\s])?$/;
117117

118118
// REMARK: see #1756 for name/username semantics

0 commit comments

Comments
 (0)