Skip to content

Commit 7f67d3c

Browse files
Copy HTTP schema to HTTPS one.
1 parent 584faf8 commit 7f67d3c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as draft4MetaSchema from "./refs/json-schema-draft-04.json"
66

77
const META_SUPPORT_DATA = ["/properties"]
88

9-
const META_SCHEMA_ID = "https://json-schema.org/draft-04/schema"
9+
const META_SCHEMA_ID = "http://json-schema.org/draft-04/schema"
1010

1111
class Ajv extends AjvCore {
1212
constructor(opts: Options = {}) {
@@ -30,6 +30,12 @@ class Ajv extends AjvCore {
3030
: draft4MetaSchema
3131
this.addMetaSchema(metaSchema, META_SCHEMA_ID, false)
3232
this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID
33+
34+
// Add a copy of the schema for HTTPS references:
35+
const httpsId = META_SCHEMA_ID.replace(/^http:/, "https:")
36+
const httpsSchema = JSON.parse(JSON.stringify(metaSchema)) as AnySchemaObject
37+
httpsSchema.id = httpsSchema.$schema = httpsId + "#"
38+
this.addMetaSchema(httpsSchema, httpsId, false)
3339
}
3440

3541
defaultMeta(): string | AnySchemaObject | undefined {

src/refs/json-schema-draft-04.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": "https://json-schema.org/draft-04/schema#",
3-
"$schema": "https://json-schema.org/draft-04/schema#",
2+
"id": "http://json-schema.org/draft-04/schema#",
3+
"$schema": "http://json-schema.org/draft-04/schema#",
44
"description": "Core schema meta-schema",
55
"definitions": {
66
"schemaArray": {

0 commit comments

Comments
 (0)