Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ designing great APIs.*
| <a href="https://pubs.opengroup.org/onlinepubs/9699919799/"><img src="./assets/ieee.svg" alt="IEEE" height="18"></a> | [IEEE Std 1003.1-2017](https://pubs.opengroup.org/onlinepubs/9699919799/) | [IEEE Standard for Information Technology—Portable Operating System Interface (POSIX)](https://pubs.opengroup.org/onlinepubs/9699919799/) |
| <a href="https://www.rfc-editor.org/rfc/rfc3066"><img src="./assets/ietf.svg" alt="IETF" height="18"></a> | [RFC 3066](https://www.rfc-editor.org/rfc/rfc3066) | [Tags for the Identification of Languages](https://www.rfc-editor.org/rfc/rfc3066) |
| <a href="https://www.rfc-editor.org/rfc/rfc3986"><img src="./assets/ietf.svg" alt="IETF" height="18"></a> | [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) | [Uniform Resource Identifier (URI): Generic Syntax](https://www.rfc-editor.org/rfc/rfc3986) |
| <a href="https://www.rfc-editor.org/rfc/rfc3987"><img src="./assets/ietf.svg" alt="IETF" height="18"></a> | [RFC 3987](https://www.rfc-editor.org/rfc/rfc3987) | [Internationalized Resource Identifiers (IRIs)](https://www.rfc-editor.org/rfc/rfc3987) |
| <a href="https://www.rfc-editor.org/rfc/rfc4648"><img src="./assets/ietf.svg" alt="IETF" height="18"></a> | [RFC 4648](https://www.rfc-editor.org/rfc/rfc4648) | [The Base16, Base32, and Base64 Data Encodings](https://www.rfc-editor.org/rfc/rfc4648) |
| <a href="https://www.rfc-editor.org/rfc/rfc4918"><img src="./assets/ietf.svg" alt="IETF" height="18"></a> | [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918) | [HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)](https://www.rfc-editor.org/rfc/rfc4918) |
| <a href="https://www.rfc-editor.org/rfc/rfc5322"><img src="./assets/ietf.svg" alt="IETF" height="18"></a> | [RFC 5322](https://www.rfc-editor.org/rfc/rfc5322) | [Internet Message Format](https://www.rfc-editor.org/rfc/rfc5322) |
Expand Down
3 changes: 3 additions & 0 deletions meta/schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
},
"description": {
"$ref": "#/$defs/single-line-text"
},
"x-format-assertion": {
"const": true
}
},
"$defs": {
Expand Down
2 changes: 1 addition & 1 deletion schemas/2020-12/ietf/ip/v4/address.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"255.255.255.255",
"10.0.0.1"
],
"x-format-assertion": true,
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.rfc-editor.org/rfc/rfc3986#section-3.2.2" ],
"type": "string",
"pattern": "^([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$",
"format": "ipv4"
}
2 changes: 1 addition & 1 deletion schemas/2020-12/ietf/ip/v6/address.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"2001:db8:85a3::8a2e:370:7334",
"fe80::1"
],
"x-format-assertion": true,
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.rfc-editor.org/rfc/rfc3986#section-3.2.2" ],
"type": "string",
"pattern": "^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\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a-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})?::)$",
"format": "ipv6"
}
5 changes: 1 addition & 4 deletions schemas/2020-12/ietf/jsonpointer/pointer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
"title": "RFC 6901 JSON Pointer",
"description": "A string syntax for identifying a specific value within a JSON document",
"examples": [ "", "/foo", "/foo/0" ],
"x-format-assertion": true,
Comment thread
jviotti marked this conversation as resolved.
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.rfc-editor.org/rfc/rfc6901" ],
"type": "string",
"not": {
"pattern": "~[^01]|~$"
},
"pattern": "^(/([^/~]|~[01])*)*$",
"format": "json-pointer"
}
17 changes: 17 additions & 0 deletions schemas/2020-12/ietf/uri/iri-reference.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "RFC 3987 Internationalized Resource Identifier (IRI) reference",
"description": "An Internationalized Resource Identifier (IRI) reference",
"examples": [
"https://example.com/path/to/resource?query=value#section",
"https://пример.рф/путь",
"../parent/fichier-é.html",
"//cdn.example.com/assets/style.css",
"?query=é#fragment"
],
"x-format-assertion": true,
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.rfc-editor.org/rfc/rfc3987#section-2.2" ],
"type": "string",
"format": "iri-reference"
}
16 changes: 16 additions & 0 deletions schemas/2020-12/ietf/uri/iri.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "RFC 3987 Internationalized Resource Identifier (IRI)",
"description": "A unique sequence of characters from the Universal Character Set that identifies an abstract or physical resource",
"examples": [
"https://example.com/path/to/resource?query=value#section",
"https://例え.jp/パス?クエリ=値#フラグメント",
"http://www.example.com/édition.html",
"mailto:usér@example.com"
],
"x-format-assertion": true,
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.rfc-editor.org/rfc/rfc3987#section-2" ],
"type": "string",
"format": "iri"
}
10 changes: 2 additions & 8 deletions schemas/2020-12/ietf/uri/uri-reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@
"//cdn.example.com/assets/style.css",
"/absolute/path/to/resource?query=value#section"
],
"x-format-assertion": true,
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.rfc-editor.org/rfc/rfc3986#section-4.1" ],
"anyOf": [
{
"$ref": "./uri.json"
},
{
"$ref": "./uri-relative.json"
}
],
"type": "string",
"format": "uri-reference"
}
27 changes: 3 additions & 24 deletions schemas/2020-12/ietf/uri/uri-relative.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"relative/path/document.pdf",
"?search=term#results"
],
"x-format-assertion": true,
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.rfc-editor.org/rfc/rfc3986#section-4.2" ],
"type": "string",
Expand All @@ -28,19 +29,9 @@
"pattern": "^/(?:[^?#]*)?(?:\\?[^#]*)?(?:#.*)?$"
},
{
"$comment": "Relative-path reference (not starting with scheme)",
"$comment": "Relative-path reference (first segment must not contain a colon)",
"not": {
"anyOf": [
{
"pattern": "^[A-Za-z][A-Za-z0-9+\\-.]*://"
},
{
"pattern": "^[A-Za-z][A-Za-z0-9+\\-.]*:[^/:?#]*@"
},
{
"pattern": "^urn:[A-Za-z0-9][A-Za-z0-9-]*:"
}
]
"pattern": "^[^/?#]*:"
},
"pattern": "^[^/?#][^?#]*(?:\\?[^#]*)?(?:#.*)?$"
},
Expand Down Expand Up @@ -77,17 +68,5 @@
"pattern": "^//(?:[^@/]*@)?\\[[0-9A-Fa-f:.]+\\](?::[0-9]+)?(?:[/?#].*)?$"
}
],
"not": {
"anyOf": [
{
"$comment": "No spaces or control characters",
"pattern": "[\\x00-\\x20]"
},
{
"$comment": "Valid percent-encoding",
"pattern": "%(?![0-9A-Fa-f]{2})"
}
]
},
"format": "uri-reference"
}
20 changes: 3 additions & 17 deletions schemas/2020-12/ietf/uri/uri.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,9 @@
"mailto:user@example.com",
"tel:+1-555-555-5555"
],
"x-format-assertion": true,
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.rfc-editor.org/rfc/rfc3986#section-3" ],
"anyOf": [
{
"$ref": "./urn.json"
},
{
"$ref": "./url.json"
},
{
"$comment": "Other absolute URI schemas that are neither URLs nor URNs (i.e. mailto, tel, data, news)",
"type": "string",
"not": {
"$comment": "Not a URL (no authority)",
"pattern": "^[A-Za-z][A-Za-z0-9+\\-.]*://"
},
"pattern": "^[A-Za-z][A-Za-z0-9+\\-.]*:.*$"
}
]
"type": "string",
"format": "uri"
}
24 changes: 2 additions & 22 deletions schemas/2020-12/ietf/uri/url.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.rfc-editor.org/rfc/rfc3986#section-3" ],
"type": "string",
"$ref": "./uri.json",
"anyOf": [
{
"$comment": "With authority (//...)",
"allOf": [
{
"$comment": "Valid authority structure - host can be empty",
"pattern": "^[^:]+://(?:[^@/]*@)?(?:\\[[^\\]]+\\]|[^:/]*)(?::[0-9]*)?(?:/.*|[?#].*)?$"
}
],
"anyOf": [
{
"$comment": "Empty host",
Expand Down Expand Up @@ -54,19 +48,5 @@
},
"pattern": "^[A-Za-z][A-Za-z0-9+\\-.]*:(?:/[^?#]*)?(?:\\?[^#]*)?(?:#.*)?$"
}
],
"not": {
"anyOf": [
{
"$comment": "Disallow spaces and control characters anywhere",
"pattern": "[\\x00-\\x20]"
},
{
"$comment": "Valid percent-encoding throughout",
"pattern": "%(?![0-9A-Fa-f]{2})"
}
]
},
"pattern": "^[A-Za-z][A-Za-z0-9+\\-.]*:.*$",
"format": "uri"
]
}
5 changes: 2 additions & 3 deletions schemas/2020-12/ietf/uri/urn.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.rfc-editor.org/rfc/rfc8141#section-2" ],
"type": "string",
"$ref": "./uri.json",
"not": {
"$comment": "Disallow reserved NID value 'urn'",
"pattern": "^[Uu][Rr][Nn]:[Uu][Rr][Nn]:"
},
"pattern": "^[Uu][Rr][Nn]:([A-Za-z0-9]([A-Za-z0-9\\-]{0,30}[A-Za-z0-9])?):((%[0-9A-Fa-f]{2}|[A-Za-z0-9\\-._~!$&'()*+,;=:@/])+)(?:\\?(?:\\+[^?#]*)?)?(?:\\?=[^#]*)?(?:#.*)?$",
"format": "uri"
"pattern": "^[Uu][Rr][Nn]:([A-Za-z0-9]([A-Za-z0-9\\-]{0,30}[A-Za-z0-9])?):((%[0-9A-Fa-f]{2}|[A-Za-z0-9\\-._~!$&'()*+,;=:@/])+)(?:\\?(?:\\+[^?#]*)?)?(?:\\?=[^#]*)?(?:#.*)?$"
}
11 changes: 8 additions & 3 deletions schemas/2020-12/w3c/xmlschema/2001/any-uri.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "W3C XML Schema anyURI",
"description": "The anyURI datatype represents a Uniform Resource Identifier Reference (URI) (§3.2.17)",
"description": "The anyURI datatype represents an Internationalized Resource Identifier (IRI) reference as defined in RFC 3987, either absolute or relative (§3.3.17)",
"examples": [
"http://www.example.com",
"https://www.example.com/path/to/resource",
"ftp://ftp.example.com/file.txt",
"mailto:user@example.com",
"../relative/path.html",
"http://www.example.com/path#fragment",
"http://www.example.com/édition.html",
"https://例え.jp/パス",
"urn:isbn:0-395-36341-1",
""
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#anyURI" ],
"$ref": "../../../ietf/uri/uri-reference.json"
"x-links": [
"https://www.w3.org/TR/xmlschema11-2/#anyURI",
"https://www.w3.org/TR/xmlschema-2/#anyURI"
],
"$ref": "../../../ietf/uri/iri-reference.json"
Comment thread
jviotti marked this conversation as resolved.
}
101 changes: 101 additions & 0 deletions test/ietf/uri/iri-reference.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"target": "../../../schemas/2020-12/ietf/uri/iri-reference.json",
"tests": [
{
"description": "Plain ASCII absolute URI",
"data": "https://example.com/path?query=value#fragment",
"valid": true
},
{
"description": "Absolute IRI with non-ASCII host and path",
"data": "https://例え.jp/パス",
"valid": true
},
{
"description": "Relative path with non-ASCII characters",
"data": "../parent/fichier-é.html",
"valid": true
},
{
"description": "Network-path reference with non-ASCII host",
"data": "//пример.рф/путь",
"valid": true
},
{
"description": "Relative path without dot segments",
"data": "относительный/путь",
"valid": true
},
{
"description": "Query and fragment only",
"data": "?query=é#fragment",
"valid": true
},
{
"description": "Empty string (same-document reference)",
"data": "",
"valid": true
},
{
"description": "Absolute path reference",
"data": "/absolute/path/to/resource",
"valid": true
},
{
"description": "Colon allowed after the first segment",
"data": "./foo:bar",
"valid": true
},
{
"description": "Space in path",
"data": "with space",
"valid": false
},
{
"description": "Malformed percent-encoding",
"data": "%ZZ",
"valid": false
},
{
"description": "Path starting with colon (first segment must not contain a colon)",
"data": ":path",
"valid": false
},
{
"description": "Path with brackets (gen-delims must be percent-encoded)",
"data": "path[with]brackets",
"valid": false
},
{
"description": "Fragment with hash in value (hash not allowed within a fragment)",
"data": "#fragment#with#hashes",
"valid": false
},
{
"description": "Number is not an IRI reference",
"data": 123,
"valid": false
},
{
"description": "Boolean is not an IRI reference",
"data": true,
"valid": false
},
{
"description": "Null is not an IRI reference",
"data": null,
"valid": false
},
{
"description": "Object is not an IRI reference",
"data": {},
"valid": false
},
{
"description": "Array is not an IRI reference",
"data": [],
"valid": false
}
]
}
Loading
Loading