Skip to content

Commit 9567c58

Browse files
authored
Merge pull request #189 from blackivory86/uri_formats
adds more valid and invalid URI testcases
2 parents 1066f7f + b9d4dbd commit 9567c58

File tree

2 files changed

+147
-2
lines changed

2 files changed

+147
-2
lines changed

tests/draft4/optional/format.json

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,80 @@
2525
"schema": {"format": "uri"},
2626
"tests": [
2727
{
28-
"description": "a valid URI",
28+
"description": "a valid URL with anchor tag",
2929
"data": "http://foo.bar/?baz=qux#quux",
3030
"valid": true
3131
},
32+
{
33+
"description": "a valid URL with anchor tag and parantheses",
34+
"data": "http://foo.com/blah_(wikipedia)_blah#cite-1",
35+
"valid": true
36+
},
37+
{
38+
"description": "a valid URL with URL-encoded stuff",
39+
"data": "http://foo.bar/?q=Test%20URL-encoded%20stuff",
40+
"valid": true
41+
},
42+
{
43+
"description": "a valid puny-coded URL ",
44+
"data": "http://xn--nw2a.xn--j6w193g/",
45+
"valid": true
46+
},
47+
{
48+
"description": "a valid URL with many special characters",
49+
"data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
50+
"valid": true
51+
},
52+
{
53+
"description": "a valid URL based on IPv4",
54+
"data": "http://223.255.255.254",
55+
"valid": true
56+
},
57+
{
58+
"description": "a valid URL with ftp scheme",
59+
"data": "ftp://ftp.is.co.za/rfc/rfc1808.txt",
60+
"valid": true
61+
},
62+
{
63+
"description": "a valid URL for a simple text file",
64+
"data": "http://www.ietf.org/rfc/rfc2396.txt",
65+
"valid": true
66+
},
67+
{
68+
"description": "a valid URL ",
69+
"data": "ldap://[2001:db8::7]/c=GB?objectClass?one",
70+
"valid": true
71+
},
72+
{
73+
"description": "a valid mailto URI",
74+
"data": "mailto:[email protected]",
75+
"valid": true
76+
},
77+
{
78+
"description": "a valid newsgroup URI",
79+
"data": "news:comp.infosystems.www.servers.unix",
80+
"valid": true
81+
},
82+
{
83+
"description": "a valid tel URI",
84+
"data": "tel:+1-816-555-1212",
85+
"valid": true
86+
},
87+
{
88+
"description": "a valid URN",
89+
"data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
90+
"valid": true
91+
},
3292
{
3393
"description": "an invalid protocol-relative URI Reference",
3494
"data": "//foo.bar/?baz=qux#quux",
3595
"valid": false
3696
},
97+
{
98+
"description": "an invalid relative URI Reference",
99+
"data": "/abc",
100+
"valid": false
101+
},
37102
{
38103
"description": "an invalid URI",
39104
"data": "\\\\WINDOWS\\fileshare",
@@ -43,6 +108,16 @@
43108
"description": "an invalid URI though valid URI reference",
44109
"data": "abc",
45110
"valid": false
111+
},
112+
{
113+
"description": "an invalid URI with spaces",
114+
"data": "http:// shouldfail.com",
115+
"valid": false
116+
},
117+
{
118+
"description": "an invalid URI with spaces and missing scheme",
119+
"data": ":// should fail",
120+
"valid": false
46121
}
47122
]
48123
},

tests/draft6/optional/format.json

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,70 @@
2525
"schema": {"format": "uri"},
2626
"tests": [
2727
{
28-
"description": "a valid URI",
28+
"description": "a valid URL with anchor tag",
2929
"data": "http://foo.bar/?baz=qux#quux",
3030
"valid": true
3131
},
32+
{
33+
"description": "a valid URL with anchor tag and parantheses",
34+
"data": "http://foo.com/blah_(wikipedia)_blah#cite-1",
35+
"valid": true
36+
},
37+
{
38+
"description": "a valid URL with URL-encoded stuff",
39+
"data": "http://foo.bar/?q=Test%20URL-encoded%20stuff",
40+
"valid": true
41+
},
42+
{
43+
"description": "a valid puny-coded URL ",
44+
"data": "http://xn--nw2a.xn--j6w193g/",
45+
"valid": true
46+
},
47+
{
48+
"description": "a valid URL with many special characters",
49+
"data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
50+
"valid": true
51+
},
52+
{
53+
"description": "a valid URL based on IPv4",
54+
"data": "http://223.255.255.254",
55+
"valid": true
56+
},
57+
{
58+
"description": "a valid URL with ftp scheme",
59+
"data": "ftp://ftp.is.co.za/rfc/rfc1808.txt",
60+
"valid": true
61+
},
62+
{
63+
"description": "a valid URL for a simple text file",
64+
"data": "http://www.ietf.org/rfc/rfc2396.txt",
65+
"valid": true
66+
},
67+
{
68+
"description": "a valid URL ",
69+
"data": "ldap://[2001:db8::7]/c=GB?objectClass?one",
70+
"valid": true
71+
},
72+
{
73+
"description": "a valid mailto URI",
74+
"data": "mailto:[email protected]",
75+
"valid": true
76+
},
77+
{
78+
"description": "a valid newsgroup URI",
79+
"data": "news:comp.infosystems.www.servers.unix",
80+
"valid": true
81+
},
82+
{
83+
"description": "a valid tel URI",
84+
"data": "tel:+1-816-555-1212",
85+
"valid": true
86+
},
87+
{
88+
"description": "a valid URN",
89+
"data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
90+
"valid": true
91+
},
3292
{
3393
"description": "an invalid protocol-relative URI Reference",
3494
"data": "//foo.bar/?baz=qux#quux",
@@ -48,6 +108,16 @@
48108
"description": "an invalid URI though valid URI reference",
49109
"data": "abc",
50110
"valid": false
111+
},
112+
{
113+
"description": "an invalid URI with spaces",
114+
"data": "http:// shouldfail.com",
115+
"valid": false
116+
},
117+
{
118+
"description": "an invalid URI with spaces and missing scheme",
119+
"data": ":// should fail",
120+
"valid": false
51121
}
52122
]
53123
},

0 commit comments

Comments
 (0)