fix: fix tianji domain update not support hostname problem

This commit is contained in:
moonrailgun 2023-10-23 00:37:30 +08:00
parent 9d50b43ebf
commit fbb091fd2a
2 changed files with 8 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import {
EVENT_COLUMNS, EVENT_COLUMNS,
FILTER_COLUMNS, FILTER_COLUMNS,
SESSION_COLUMNS, SESSION_COLUMNS,
hostnameRegex,
} from '../../utils/const'; } from '../../utils/const';
import { parseDateRange } from '../../utils/common'; import { parseDateRange } from '../../utils/common';
import { getSessionMetrics, getPageviewMetrics } from '../../model/website'; import { getSessionMetrics, getPageviewMetrics } from '../../model/website';
@ -160,7 +161,10 @@ export const websiteRouter = router({
z.object({ z.object({
websiteId: z.string().cuid2(), websiteId: z.string().cuid2(),
name: z.string().max(100), name: z.string().max(100),
domain: z.union([z.string().max(500).url(), z.string().max(500).ip()]), domain: z.union([
z.string().max(500).regex(hostnameRegex),
z.string().max(500).ip(),
]),
monitorId: z.string().cuid2().nullish(), monitorId: z.string().cuid2().nullish(),
}) })
) )

View File

@ -117,3 +117,6 @@ export const DEFAULT_RESET_DATE = '2000-01-01';
export enum OPENAPI_TAG { export enum OPENAPI_TAG {
USER = 'User', USER = 'User',
} }
export const hostnameRegex =
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/gim;