summaryrefslogtreecommitdiff
path: root/lib/v8.js
diff options
context:
space:
mode:
authorZYSzys <zyszys98@gmail.com>2019-05-12 20:30:29 +0800
committerRich Trott <rtrott@gmail.com>2019-05-14 15:13:48 -0700
commit23ef3e4cfb8da65b205e6895947375e5284bebdc (patch)
tree41f5465e41fbabd16c82bc3fc44b566a427e823c /lib/v8.js
parent4a18b87a3ff7e22625c049f28c4b9b413eb3e450 (diff)
downloadandroid-node-v8-23ef3e4cfb8da65b205e6895947375e5284bebdc.tar.gz
android-node-v8-23ef3e4cfb8da65b205e6895947375e5284bebdc.tar.bz2
android-node-v8-23ef3e4cfb8da65b205e6895947375e5284bebdc.zip
fs: extract path conversion and validation to getValidatedPath
Almost all path validations within our file system are combined with: ```js path = toPathIfFileURL(path); validatePath(path); ``` So simply extracted them out into `getValidatedPath` function to `internal/fs/utils.js` to DRY up the code and reduce duplicating them. PR-URL: https://github.com/nodejs/node/pull/27656 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/v8.js')
-rw-r--r--lib/v8.js6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/v8.js b/lib/v8.js
index efce85533d..2bede41291 100644
--- a/lib/v8.js
+++ b/lib/v8.js
@@ -25,8 +25,7 @@ const {
const assert = require('internal/assert');
const { copy } = internalBinding('buffer');
const { FastBuffer } = require('internal/buffer');
-const { toPathIfFileURL } = require('internal/url');
-const { validatePath } = require('internal/fs/utils');
+const { getValidatedPath } = require('internal/fs/utils');
const { toNamespacedPath } = require('path');
const {
createHeapSnapshotStream,
@@ -43,8 +42,7 @@ const kHandle = Symbol('kHandle');
function writeHeapSnapshot(filename) {
if (filename !== undefined) {
- filename = toPathIfFileURL(filename);
- validatePath(filename);
+ filename = getValidatedPath(filename);
filename = toNamespacedPath(filename);
}
return triggerHeapSnapshot(filename);