Debian Codegraph @

path2/test/windows/join.js

raw
1 'use strict';
2
3 module.exports = exports = function (t, a) { exports.tests(t, a); };
4
5 var data = exports.data = require('../posix/join').data.concat([
6 // UNC path expected
7 [['//foo/bar'], '//foo/bar/'],
8 [['\\/foo/bar'], '//foo/bar/'],
9 [['\\\\foo/bar'], '//foo/bar/'],
10 // UNC path expected - server and share separate
11 [['//foo', 'bar'], '//foo/bar/'],
12 [['//foo/', 'bar'], '//foo/bar/'],
13 [['//foo', '/bar'], '//foo/bar/'],
14 // UNC path expected - questionable
15 [['//foo', '', 'bar'], '//foo/bar/'],
16 [['//foo/', '', 'bar'], '//foo/bar/'],
17 [['//foo/', '', '/bar'], '//foo/bar/'],
18 // UNC path expected - even more questionable
19 [['', '//foo', 'bar'], '//foo/bar/'],
20 [['', '//foo/', 'bar'], '//foo/bar/'],
21 [['', '//foo/', '/bar'], '//foo/bar/'],
22 // No UNC path expected (no double slash in first component)
23 [['\\', 'foo/bar'], '/foo/bar'],
24 [['\\', '/foo/bar'], '/foo/bar'],
25 [['', '/', '/foo/bar'], '/foo/bar'],
26 // No UNC path expected (no non-slashes in first component - questionable)
27 [['//', 'foo/bar'], '/foo/bar'],
28 [['//', '/foo/bar'], '/foo/bar'],
29 [['\\\\', '/', '/foo/bar'], '/foo/bar'],
30 [['//'], '/'],
31 // No UNC path expected (share name missing - questionable).
32 [['//foo'], '/foo'],
33 [['//foo/'], '/foo/'],
34 [['//foo', '/'], '/foo/'],
35 [['//foo', '', '/'], '/foo/'],
36 // No UNC path expected (too many leading slashes - questionable)
37 [['///foo/bar'], '/foo/bar'],
38 [['////foo', 'bar'], '/foo/bar'],
39 [['\\\\\\/foo/bar'], '/foo/bar'],
40 // Drive-relative vs drive-absolute paths. This merely describes the
41 // status quo, rather than being obviously right
42 [['c:'], 'c:.'],
43 [['c:.'], 'c:.'],
44 [['c:', ''], 'c:.'],
45 [['', 'c:'], 'c:.'],
46 [['c:.', '/'], 'c:./'],
47 [['c:.', 'file'], 'c:file'],
48 [['c:', '/'], 'c:/'],
49 [['c:', 'file'], 'c:/file']
50 ]);
51
52 exports.tests = function (t, a) {
53 data.forEach(function (test, i) {
54 a(t.apply(null, test[0]), test[1].replace(/\//g, '\\'), i);
55 });
56 };