-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
83 lines (79 loc) · 3.24 KB
/
test.js
File metadata and controls
83 lines (79 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import test from 'ava'
import m from './'
test('other types must return false', t => {
t.false(m())
t.false(m(''))
t.false(m(undefined))
t.false(m(123))
t.false(m(true))
t.false(m(false))
t.false(m(() => {}))
t.false(m([]))
t.false(m({}))
t.false(m(null))
t.false(m(Symbol('')))
})
test('check url protocol without slashes', t => {
t.true(m('mailto:[email protected]'))
t.true(m('news:rec.gardens.roses'))
t.true(m('xmpp:user@host?message&subject=hi&body=Hello%20World&thread=abc123'))
t.true(m('data:image/gif;base64,R0lGODlhyAAiALMDfD0QAADs='))
t.true(m('tel:9008007060'))
t.true(m('cid:foo4*[email protected]'))
t.true(m('mid:[email protected]/[email protected]'))
t.true(m('skype:login?chat'))
t.true(m('smsto:8881234567?body=hello!'))
t.true(m('bitcoin:19UBzu6Bt4bsx7eTb7eryFWKJ7TF8Bwtnf'))
t.true(m('virtual:some/foo//bar'))
t.true(m('virtual:duplicate-virtual://foo-bar.com'))
})
test('check url protocol with slashes', t => {
t.false(m('site.com'))
t.false(m('http://admin:[email protected]'))
t.false(m('http://admin:[email protected]:3000'))
t.false(m('http://admin:[email protected]:3000/a'))
t.false(m('http://admin:[email protected]:3000/a/b/./c'))
t.false(m('http://admin:[email protected]:3000/a/b/../c'))
t.false(m('http://admin:[email protected]:3000/a/b/../c/d.js'))
t.false(m('http://admin:[email protected]/foo//bar'))
t.false(m('http://admin:[email protected]/foo/http://test.com'))
t.false(m('//site.com'))
t.false(m('//site.com:3000'))
t.false(m('//site.com:3000/a'))
t.false(m('//site.com:3000/a/b/./c'))
t.false(m('//site.com:3000/a/b/../c'))
t.false(m('//site.com:3000/a/b/../c/d.js'))
t.false(m('//admin:[email protected]'))
t.false(m('//admin:[email protected]:3000'))
t.false(m('//admin:[email protected]:3000/a'))
t.false(m('//admin:[email protected]:3000/a/b/./c'))
t.false(m('//admin:[email protected]:3000/a/b/../c'))
t.false(m('//admin:[email protected]:3000/a/b/../c/d.js'))
t.false(m('ftp://user:password@host:port/path'))
t.false(m('http://test.com'))
t.false(m('http://test.com:1234'))
t.false(m('http://test.com:1234/a'))
t.false(m('http://test.com:1234/a/b/./c'))
t.false(m('http://test.com:1234/a/b/../c'))
t.false(m('http://test.com:1234/a/b/../c/d.js'))
t.false(m('rtmp://mycompany.com/vod/mp4:mycoolvideo.mov'))
t.false(m('sftp://[email protected]/home/test/'))
t.false(m('rtsp://ip_address/MediaInput/h264'))
t.false(m('https://test.com'))
t.false(m('gopher://gopher.cc.lehigh.edu'))
t.false(m('nntp://news.cs.hut.fi/alt.html/239157'))
t.false(m('irc://foobar.org:6665/secret,needkey'))
t.false(m('smb://host/share/'))
t.false(m('prospero://host:port/hsoname;field=value'))
t.false(m('telnet://user:password@host:port/'))
t.false(m('wais://vega.lib.ncsu.edu/alawon.src?nren'))
t.false(m('file://localhost/etc/fstab'))
t.false(m('afp://myserver.mydomain.com/Sharepoint/Folder'))
t.false(m('nfs://server:port/path'))
t.false(m('TN3270://TN3270site:23/'))
t.false(m('z3950://habanero.nhm.ukans.edu/kubirds/search?query=(@attr%201=1%20"falco")'))
t.false(m('ed2k://|file|The_Two_Towers-The_Purist_Edit-Trailer.avi|14997504|965c013e991ee246d63d45ea71954c4d|/'))
t.false(m('market://details?id=package_name'))
t.false(m('steam://install/id'))
t.false(m('tg://addstickers?set=vk_nichosi'))
})