doc: pass path in URL constructor

PR-URL: https://github.com/nodejs/node/pull/28161
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
This commit is contained in:
Daniel Nalborczyk 2019-06-10 18:26:34 -04:00 committed by ZYSzys
parent d4c7487840
commit b5e818197f

View File

@ -467,8 +467,7 @@ The resolve hook returns the resolved file URL and module format for a
given module specifier and parent file URL:
```js
const baseURL = new URL('file://');
baseURL.pathname = `${process.cwd()}/`;
const baseURL = new URL(`${process.cwd()}/`, 'file://');
export async function resolve(specifier,
parentModuleURL = baseURL,
@ -511,8 +510,7 @@ import Module from 'module';
const builtins = Module.builtinModules;
const JS_EXTENSIONS = new Set(['.js', '.mjs']);
const baseURL = new URL('file://');
baseURL.pathname = `${process.cwd()}/`;
const baseURL = new URL(`${process.cwd()}/`, 'file://');
export function resolve(specifier, parentModuleURL = baseURL, defaultResolve) {
if (builtins.includes(specifier)) {