-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.js
34 lines (30 loc) · 1.01 KB
/
test.js
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
'use strict';
/* deps:mocha */
var assert = require('assert');
var regex = require('./');
function unc(str) {
return regex().test(str);
}
describe('UNC path regex', function () {
it('should return true for UNC paths', function () {
assert.equal(unc('\\/foo/bar'), true);
assert.equal(unc('\\\\foo/bar'), true);
assert.equal(unc('\\\\foo\\admin$'), true);
assert.equal(unc('\\\\foo\\admin$\\system32'), true);
assert.equal(unc('\\\\foo\\temp'), true);
assert.equal(unc('\\\\/foo/bar'), true);
assert.equal(unc('\\\\\\/foo/bar'), true);
});
it('should return false for non-UNC paths', function () {
assert.equal(unc('/foo/bar'), false);
assert.equal(unc('/'), false);
assert.equal(unc('/foo'), false);
assert.equal(unc('/foo/'), false);
assert.equal(unc('c:'), false);
assert.equal(unc('c:.'), false);
assert.equal(unc('c:./'), false);
assert.equal(unc('c:./file'), false);
assert.equal(unc('c:/'), false);
assert.equal(unc('c:/file'), false);
});
});