Skip to content

Commit 6fbc3db

Browse files
authored
fix: allow underscores in domain name segments (#421)
Update domain name validation regex to permit underscores in domain segments, expanding support for package naming conventions. Fixed #420
1 parent 0b70a3a commit 6fbc3db

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/domain/domain-name.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { z } from "zod";
22

3-
const segmentRegex = /^(?!.*--|^-.*|.*-$)[a-zA-Z0-9-]+$/;
3+
const segmentRegex = /^(?!.*--|^-.*|.*-$)[a-zA-Z0-9-_]+$/;
44

55
function domainSegmentsIn(hostName: string): string[] {
66
return hostName.split(".");

test/unit/domain/domain-name.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe("domain-name", () => {
99
"com.openupm",
1010
"at.ac.my-school",
1111
"dev.comradevanti123",
12+
"org.nuget.sqlitepclraw.bundle_e_sqlite3",
1213
])(`should be ok for "%s"`, (s) => {
1314
expect(isZod(s, DomainName)).toBeTruthy();
1415
});

0 commit comments

Comments
 (0)