blob: bfdf0022f421c3e6c1666b1451a333badd13e606 (
plain)
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
|
// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('internal/fs/utils');
// Valid encodings and no args should not throw.
fs.assertEncoding();
fs.assertEncoding('utf8');
common.expectsError(
() => fs.assertEncoding('foo'),
{ code: 'ERR_INVALID_OPT_VALUE_ENCODING', type: TypeError }
);
// Test junction symlinks
{
const pathString = 'c:\\test1';
const linkPathString = '\\test2';
const preprocessSymlinkDestination = fs.preprocessSymlinkDestination(
pathString,
'junction',
linkPathString
);
if (process.platform === 'win32') {
assert.strictEqual(/^\\\\\?\\/.test(preprocessSymlinkDestination), true);
} else {
assert.strictEqual(preprocessSymlinkDestination, pathString);
}
}
// Test none junction symlinks
{
const pathString = 'c:\\test1';
const linkPathString = '\\test2';
const preprocessSymlinkDestination = fs.preprocessSymlinkDestination(
pathString,
undefined,
linkPathString
);
if (process.platform === 'win32') {
// There should not be any forward slashes
assert.strictEqual(
/\//.test(preprocessSymlinkDestination), false);
} else {
assert.strictEqual(preprocessSymlinkDestination, pathString);
}
}
|