summaryrefslogtreecommitdiff
path: root/doc/api/esm.md
diff options
context:
space:
mode:
authorDaniel Nalborczyk <dnalborczyk@gmail.com>2019-06-10 18:26:34 -0400
committerZYSzys <zyszys98@gmail.com>2019-06-14 17:19:21 +0800
commitb5e818197f127b36f18fb0d0481928227b88b053 (patch)
tree6af7ef62c25fd8a72b00c99902a082af0d68c7e8 /doc/api/esm.md
parentd4c7487840c8b2b6852951d3e0623ed16206e2e6 (diff)
downloadandroid-node-v8-b5e818197f127b36f18fb0d0481928227b88b053.tar.gz
android-node-v8-b5e818197f127b36f18fb0d0481928227b88b053.tar.bz2
android-node-v8-b5e818197f127b36f18fb0d0481928227b88b053.zip
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>
Diffstat (limited to 'doc/api/esm.md')
-rw-r--r--doc/api/esm.md6
1 files changed, 2 insertions, 4 deletions
diff --git a/doc/api/esm.md b/doc/api/esm.md
index c89408963f..c4edc52357 100644
--- a/doc/api/esm.md
+++ b/doc/api/esm.md
@@ -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)) {