mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
url: provide pathToFileURL and fileURLToPath
PR-URL: https://github.com/nodejs/node/pull/22506 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
This commit is contained in:
1 parent
0d3da39f57
commit
eef072fa08
13 files changed
+208
-112
No files matched your search
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
const { isWindows } = require('../common');
|
||||
const assert = require('assert');
|
||||
const url = require('url');
|
||||
|
||||
{
|
||||
const fileURL = url.pathToFileURL('test/').href;
|
||||
assert.ok(fileURL.startsWith('file:///'));
|
||||
assert.ok(fileURL.endsWith('/'));
|
||||
}
|
||||
|
||||
{
|
||||
const fileURL = url.pathToFileURL('test\\').href;
|
||||
assert.ok(fileURL.startsWith('file:///'));
|
||||
if (isWindows)
|
||||
assert.ok(fileURL.endsWith('/'));
|
||||
else
|
||||
assert.ok(fileURL.endsWith('%5C'));
|
||||
}
|
||||
|
||||
{
|
||||
const fileURL = url.pathToFileURL('test/%').href;
|
||||
assert.ok(fileURL.includes('%25'));
|
||||
}
|
||||
Reference in new issue
Block a user