mirror of
https://github.com/langgenius/dify.git
synced 2026-04-15 09:57:03 +08:00
fix: handle URL construction error when switching to Visual Editor (#35004)
Co-authored-by: Sami Rusani <sr@samirusani> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
bd30784b1d
commit
25a33a454c
@ -1,11 +1,21 @@
|
||||
import type { Schema } from 'jsonschema'
|
||||
import type { Schema, ValidationError, ValidatorResult } from 'jsonschema'
|
||||
import { Validator } from 'jsonschema'
|
||||
import draft07Schema from './draft-07.json'
|
||||
|
||||
const validator = new Validator()
|
||||
|
||||
export const draft07Validator = (schema: any) => {
|
||||
return validator.validate(schema, draft07Schema as unknown as Schema)
|
||||
type Draft07ValidationResult = Pick<ValidatorResult, 'valid' | 'errors'>
|
||||
|
||||
export const draft07Validator = (schema: any): Draft07ValidationResult => {
|
||||
try {
|
||||
return validator.validate(schema, draft07Schema as unknown as Schema)
|
||||
}
|
||||
catch {
|
||||
// The jsonschema library may throw URL errors in browser environments
|
||||
// when resolving schema $id URIs. Return empty errors since structural
|
||||
// validation is handled separately by preValidateSchema (#34841).
|
||||
return { valid: true, errors: [] as ValidationError[] }
|
||||
}
|
||||
}
|
||||
|
||||
export const forbidBooleanProperties = (schema: any, path: string[] = []): string[] => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user