Skip to content

Commit d93b657

Browse files
committed
Fixes
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent f1b9cb3 commit d93b657

7 files changed

Lines changed: 345 additions & 2 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ lint: common
2020
$(JSONSCHEMA) fmt schemas tests conventions.json tests.json --verbose --check
2121

2222
test: .always
23-
$(JSONSCHEMA) test ./tests --verbose
23+
$(JSONSCHEMA) test ./tests
2424

2525
.always:

conventions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"$id": false,
1717
"$comment": {
18-
"$ref": "./schemas/ietf/uri/url.json"
18+
"$ref": "./schemas/ietf/http/https-url.json"
1919
},
2020
"examples": {
2121
"type": "array",

schemas/ietf/http/http-url.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "HTTP URL",
4+
"description": "A Uniform Resource Locator using the HTTP scheme",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-4.2.1",
6+
"examples": [
7+
"http://example.com",
8+
"http://example.com/path",
9+
"http://user:pass@example.com:8080/api"
10+
],
11+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
12+
"$ref": "../uri/url.json",
13+
"pattern": "^[Hh][Tt][Tt][Pp]://"
14+
}

schemas/ietf/http/https-url.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "HTTPS URL",
4+
"description": "A Uniform Resource Locator using the HTTPS scheme",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-4.2.2",
6+
"examples": [
7+
"https://example.com",
8+
"https://example.com/path",
9+
"https://user:pass@example.com:443/api"
10+
],
11+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
12+
"$ref": "../uri/url.json",
13+
"pattern": "^[Hh][Tt][Tt][Pp][Ss]://"
14+
}

schemas/ietf/http/method.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
"examples": [ "GET", "POST", "PUT", "PATCH" ],
77
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
88
"type": "string",
9+
"not": {
10+
"pattern": "[\\x00-\\x1F\\x7F]"
11+
},
912
"pattern": "^[!#$%&'*+\\-.0-9A-Z^_`a-z|~]+$"
1013
}

tests/ietf/http/http-url.test.json

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{
2+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
3+
"target": "../../../schemas/ietf/http/http-url.json",
4+
"tests": [
5+
{
6+
"description": "Invalid type - number",
7+
"data": 123,
8+
"valid": false
9+
},
10+
{
11+
"description": "Invalid type - boolean",
12+
"data": true,
13+
"valid": false
14+
},
15+
{
16+
"description": "Invalid type - null",
17+
"data": null,
18+
"valid": false
19+
},
20+
{
21+
"description": "Invalid type - array",
22+
"data": [],
23+
"valid": false
24+
},
25+
{
26+
"description": "Invalid type - object",
27+
"data": {},
28+
"valid": false
29+
},
30+
{
31+
"description": "Valid - simple HTTP URL",
32+
"data": "http://example.com",
33+
"valid": true
34+
},
35+
{
36+
"description": "Valid - HTTP URL with path",
37+
"data": "http://example.com/path/to/resource",
38+
"valid": true
39+
},
40+
{
41+
"description": "Valid - HTTP URL with query",
42+
"data": "http://example.com/path?query=value",
43+
"valid": true
44+
},
45+
{
46+
"description": "Valid - HTTP URL with fragment",
47+
"data": "http://example.com/path#section",
48+
"valid": true
49+
},
50+
{
51+
"description": "Valid - HTTP URL with port",
52+
"data": "http://example.com:8080/api",
53+
"valid": true
54+
},
55+
{
56+
"description": "Valid - HTTP URL with userinfo",
57+
"data": "http://user:pass@example.com/resource",
58+
"valid": true
59+
},
60+
{
61+
"description": "Valid - HTTP URL with IPv4",
62+
"data": "http://192.168.1.1/path",
63+
"valid": true
64+
},
65+
{
66+
"description": "Valid - HTTP URL with IPv6",
67+
"data": "http://[2001:db8::8a2e:370:7334]/path",
68+
"valid": true
69+
},
70+
{
71+
"description": "Valid - HTTP scheme uppercase",
72+
"data": "HTTP://example.com",
73+
"valid": true
74+
},
75+
{
76+
"description": "Valid - HTTP scheme mixed case Http",
77+
"data": "Http://example.com",
78+
"valid": true
79+
},
80+
{
81+
"description": "Valid - HTTP scheme mixed case HtTp",
82+
"data": "HtTp://example.com",
83+
"valid": true
84+
},
85+
{
86+
"description": "Valid - HTTP scheme mixed case hTTP",
87+
"data": "hTTP://example.com",
88+
"valid": true
89+
},
90+
{
91+
"description": "Valid - HTTP URL with all components",
92+
"data": "http://user:pass@example.com:8080/path/to/resource?query=value&foo=bar#section",
93+
"valid": true
94+
},
95+
{
96+
"description": "Valid - HTTP URL with empty path",
97+
"data": "http://example.com",
98+
"valid": true
99+
},
100+
{
101+
"description": "Valid - HTTP URL with port 80",
102+
"data": "http://example.com:80/",
103+
"valid": true
104+
},
105+
{
106+
"description": "Invalid - HTTPS URL",
107+
"data": "https://example.com",
108+
"valid": false
109+
},
110+
{
111+
"description": "Invalid - FTP URL",
112+
"data": "ftp://example.com",
113+
"valid": false
114+
},
115+
{
116+
"description": "Invalid - file URL",
117+
"data": "file:///path/to/file",
118+
"valid": false
119+
},
120+
{
121+
"description": "Invalid - mailto URL",
122+
"data": "mailto:user@example.com",
123+
"valid": false
124+
},
125+
{
126+
"description": "Invalid - relative URL",
127+
"data": "/path/to/resource",
128+
"valid": false
129+
},
130+
{
131+
"description": "Invalid - missing scheme",
132+
"data": "example.com/path",
133+
"valid": false
134+
},
135+
{
136+
"description": "Invalid - empty string",
137+
"data": "",
138+
"valid": false
139+
},
140+
{
141+
"description": "Invalid - scheme only",
142+
"data": "http:",
143+
"valid": false
144+
},
145+
{
146+
"description": "Invalid - scheme with single slash",
147+
"data": "http:/example.com",
148+
"valid": false
149+
},
150+
{
151+
"description": "Invalid - HTTP URL with space",
152+
"data": "http://example.com/path with space",
153+
"valid": false
154+
}
155+
]
156+
}
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{
2+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
3+
"target": "../../../schemas/ietf/http/https-url.json",
4+
"tests": [
5+
{
6+
"description": "Invalid type - number",
7+
"data": 123,
8+
"valid": false
9+
},
10+
{
11+
"description": "Invalid type - boolean",
12+
"data": true,
13+
"valid": false
14+
},
15+
{
16+
"description": "Invalid type - null",
17+
"data": null,
18+
"valid": false
19+
},
20+
{
21+
"description": "Invalid type - array",
22+
"data": [],
23+
"valid": false
24+
},
25+
{
26+
"description": "Invalid type - object",
27+
"data": {},
28+
"valid": false
29+
},
30+
{
31+
"description": "Valid - simple HTTPS URL",
32+
"data": "https://example.com",
33+
"valid": true
34+
},
35+
{
36+
"description": "Valid - HTTPS URL with path",
37+
"data": "https://example.com/path/to/resource",
38+
"valid": true
39+
},
40+
{
41+
"description": "Valid - HTTPS URL with query",
42+
"data": "https://example.com/path?query=value",
43+
"valid": true
44+
},
45+
{
46+
"description": "Valid - HTTPS URL with fragment",
47+
"data": "https://example.com/path#section",
48+
"valid": true
49+
},
50+
{
51+
"description": "Valid - HTTPS URL with port",
52+
"data": "https://example.com:8443/api",
53+
"valid": true
54+
},
55+
{
56+
"description": "Valid - HTTPS URL with userinfo",
57+
"data": "https://user:pass@example.com/resource",
58+
"valid": true
59+
},
60+
{
61+
"description": "Valid - HTTPS URL with IPv4",
62+
"data": "https://192.168.1.1/path",
63+
"valid": true
64+
},
65+
{
66+
"description": "Valid - HTTPS URL with IPv6",
67+
"data": "https://[2001:db8::8a2e:370:7334]/path",
68+
"valid": true
69+
},
70+
{
71+
"description": "Valid - HTTPS scheme uppercase",
72+
"data": "HTTPS://example.com",
73+
"valid": true
74+
},
75+
{
76+
"description": "Valid - HTTPS scheme mixed case Https",
77+
"data": "Https://example.com",
78+
"valid": true
79+
},
80+
{
81+
"description": "Valid - HTTPS scheme mixed case HtTpS",
82+
"data": "HtTpS://example.com",
83+
"valid": true
84+
},
85+
{
86+
"description": "Valid - HTTPS scheme mixed case hTTPS",
87+
"data": "hTTPS://example.com",
88+
"valid": true
89+
},
90+
{
91+
"description": "Valid - HTTPS URL with all components",
92+
"data": "https://user:pass@example.com:8443/path/to/resource?query=value&foo=bar#section",
93+
"valid": true
94+
},
95+
{
96+
"description": "Valid - HTTPS URL with empty path",
97+
"data": "https://example.com",
98+
"valid": true
99+
},
100+
{
101+
"description": "Valid - HTTPS URL with port 443",
102+
"data": "https://example.com:443/",
103+
"valid": true
104+
},
105+
{
106+
"description": "Invalid - HTTP URL",
107+
"data": "http://example.com",
108+
"valid": false
109+
},
110+
{
111+
"description": "Invalid - FTP URL",
112+
"data": "ftp://example.com",
113+
"valid": false
114+
},
115+
{
116+
"description": "Invalid - file URL",
117+
"data": "file:///path/to/file",
118+
"valid": false
119+
},
120+
{
121+
"description": "Invalid - mailto URL",
122+
"data": "mailto:user@example.com",
123+
"valid": false
124+
},
125+
{
126+
"description": "Invalid - relative URL",
127+
"data": "/path/to/resource",
128+
"valid": false
129+
},
130+
{
131+
"description": "Invalid - missing scheme",
132+
"data": "example.com/path",
133+
"valid": false
134+
},
135+
{
136+
"description": "Invalid - empty string",
137+
"data": "",
138+
"valid": false
139+
},
140+
{
141+
"description": "Invalid - scheme only",
142+
"data": "https:",
143+
"valid": false
144+
},
145+
{
146+
"description": "Invalid - scheme with single slash",
147+
"data": "https:/example.com",
148+
"valid": false
149+
},
150+
{
151+
"description": "Invalid - HTTPS URL with space",
152+
"data": "https://example.com/path with space",
153+
"valid": false
154+
}
155+
]
156+
}

0 commit comments

Comments
 (0)