1 | var test = require("tap").test,
|
2 | is_uri = require('../').is_uri;
|
3 |
|
4 | test("testing is_uri", function (t) {
|
5 |
|
6 |
|
7 | t.ok(is_uri('http://localhost/'), 'http://localhost/');
|
8 | t.ok(is_uri('http://example.w3.org/path%20with%20spaces.html'), 'http://example.w3.org/path%20with%20spaces.html');
|
9 | t.ok(is_uri('http://example.w3.org/%20'), 'http://example.w3.org/%20');
|
10 | t.ok(is_uri('ftp://ftp.is.co.za/rfc/rfc1808.txt'), 'ftp://ftp.is.co.za/rfc/rfc1808.txt');
|
11 | t.ok(is_uri('ftp://ftp.is.co.za/../../../rfc/rfc1808.txt'), 'ftp://ftp.is.co.za/../../../rfc/rfc1808.txt');
|
12 | t.ok(is_uri('http://www.ietf.org/rfc/rfc2396.txt'), 'http://www.ietf.org/rfc/rfc2396.txt');
|
13 | t.ok(is_uri('ldap://[2001:db8::7]/c=GB?objectClass?one'), 'ldap://[2001:db8::7]/c=GB?objectClass?one');
|
14 | t.ok(is_uri('mailto:John.Doe@example.com'), 'mailto:John.Doe@example.com');
|
15 | t.ok(is_uri('news:comp.infosystems.www.servers.unix'), 'news:comp.infosystems.www.servers.unix');
|
16 | t.ok(is_uri('tel:+1-816-555-1212'), 'tel:+1-816-555-1212');
|
17 | t.ok(is_uri('telnet://192.0.2.16:80/'), 'telnet://192.0.2.16:80/');
|
18 | t.ok(is_uri('urn:oasis:names:specification:docbook:dtd:xml:4.1.2'), 'urn:oasis:names:specification:docbook:dtd:xml:4.1.2');
|
19 |
|
20 |
|
21 |
|
22 | t.notOk(is_uri(''), "bad: ''");
|
23 | t.notOk(is_uri('foo'), 'bad: foo');
|
24 | t.notOk(is_uri('foo@bar'), 'bad: foo@bar');
|
25 | t.notOk(is_uri('http://<foo>'), 'bad: http://<foo>');
|
26 | t.notOk(is_uri('://bob/'), 'bad: ://bob/');
|
27 | t.notOk(is_uri('1http://bob'), 'bad: 1http://bob/');
|
28 | t.notOk(is_uri('1http:////foo.html'), 'bad: 1http://bob/');
|
29 | t.notOk(is_uri('http://example.w3.org/%illegal.html'), 'http://example.w3.org/%illegal.html');
|
30 | t.notOk(is_uri('http://example.w3.org/%a'), 'http://example.w3.org/%a');
|
31 | t.notOk(is_uri('http://example.w3.org/%a/foo'), 'http://example.w3.org/%a/foo');
|
32 | t.notOk(is_uri('http://example.w3.org/%at'), 'http://example.w3.org/%at');
|
33 |
|
34 | t.end();
|
35 | });
|