Skip to content

Commit 732e182

Browse files
committed
test: add test case for device paths missing colon
1 parent 513ccb7 commit 732e182

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const path = require('path');
5+
6+
// هذا السطر يمنع تشغيل الاختبار على غير ويندوز لأنه خاص بويندوز فقط
7+
if (!common.isWindows)
8+
common.skip('this test is for win32 only');
9+
10+
// Test cases for reserved device names missing the trailing colon
11+
// See: https://github.com/nodejs/node/pull/[YOUR_PR_NUMBER] (optional)
12+
13+
// 1. Check \\.\CON (Missing colon)
14+
assert.strictEqual(path.win32.normalize('\\\\.\\CON'), '\\\\.\\CON');
15+
assert.strictEqual(path.win32.normalize('\\\\.\\con'), '\\\\.\\con'); // Case insensitive
16+
17+
// 2. Check \\?\CON (Missing colon)
18+
assert.strictEqual(path.win32.normalize('\\\\?\\CON'), '\\\\?\\CON');
19+
assert.strictEqual(path.win32.normalize('\\\\?\\con'), '\\\\?\\con');
20+
21+
// 3. Check that regular files are NOT affected (Sanity check)
22+
assert.strictEqual(path.win32.normalize('\\\\.\\PhysicalDrive0'), '\\\\.\\PhysicalDrive0');
23+
24+
// 4. Check join behavior (to ensure it acts as a root)
25+
// If it's a root, joining '..' should not strip the device.
26+
const joined = path.win32.join('\\\\.\\CON', '..');
27+
assert.strictEqual(joined, '\\\\.\\CON');

0 commit comments

Comments
 (0)