Skip to content

Commit

Permalink
Fix devbox name regx (#5340)
Browse files Browse the repository at this point in the history
* fix(devbox): fix devbox name

* fix(devbox): fix show error
  • Loading branch information
xudaotutou authored Jan 10, 2025
1 parent 7f9085f commit af8e841
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions frontend/providers/devbox/services/backend/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@ export const jsonRes = <T = any>(props: {
return NextResponse.json(ERROR_RESPONSE[error])
}
const body = error?.body
if(body instanceof V1Status && body.message?.includes('40001:')) {
return NextResponse.json(ERROR_RESPONSE[ERROR_ENUM.outstandingPayment])
if (body instanceof V1Status) {
if (body.message?.includes('40001:')) {
return NextResponse.json(ERROR_RESPONSE[ERROR_ENUM.outstandingPayment])
} else {
return NextResponse.json({
code: 500,
statusText: body.message,
message: body.message,
})
}
}

let msg = message
if ((code < 200 || code >= 400) && !message) {
if(code >= 500) {
if (code >= 500) {
console.log(error)
msg = 'Internal Server Error'
} else {
Expand All @@ -34,7 +42,7 @@ export const jsonRes = <T = any>(props: {
}
console.log('===jsonRes===\n', error)
}
if(code >= 500) {
if (code >= 500) {
return NextResponse.json({
code,
statusText: '',
Expand Down
2 changes: 1 addition & 1 deletion frontend/providers/devbox/utils/vaildate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const versionSchema = z.string().min(1).regex(/[\w][\w.-]{0,127}/, {
message: versionErrorEnum.INVALID_VERSION,
});
export const templateNameSchema = z.string().regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/);
export const devboxNameSchema = z.string().regex(/^[a-z]([-a-z0-9]*[a-z0-9])?/);
export const devboxNameSchema = z.string().regex(/^[a-z]([-a-z0-9]*[a-z0-9])?$/);
export const createTemplateRepositorySchema = z.object({
description: z.string().max(255),
version: z.string().min(1).max(255),
Expand Down

0 comments on commit af8e841

Please sign in to comment.