aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.js/path.exports.js7
-rw-r--r--test/js/node/path/path.test.js4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/bun.js/path.exports.js b/src/bun.js/path.exports.js
index 41d437bd0..8879771ab 100644
--- a/src/bun.js/path.exports.js
+++ b/src/bun.js/path.exports.js
@@ -1,5 +1,8 @@
+// Utils to extract later
+const createModule = (obj) => Object.assign(Object.create(null), obj);
+
function bound(obj) {
- var result = {
+ var result = createModule({
basename: obj.basename.bind(obj),
dirname: obj.dirname.bind(obj),
extname: obj.extname.bind(obj),
@@ -13,7 +16,7 @@ function bound(obj) {
toNamespacedPath: obj.toNamespacedPath.bind(obj),
sep: obj.sep,
delimiter: obj.delimiter,
- };
+ });
result.default = result;
return result;
}
diff --git a/test/js/node/path/path.test.js b/test/js/node/path/path.test.js
index ad5688ea7..ce41ca10f 100644
--- a/test/js/node/path/path.test.js
+++ b/test/js/node/path/path.test.js
@@ -9,6 +9,10 @@ const strictEqual = (...args) => {
expect(true).toBe(true);
};
+it('should not inherit Object.prototype', () => {
+ expect(path).not.toHaveProperty('toString');
+});
+
it("path.basename", () => {
strictEqual(path.basename(file), "path.test.js");
strictEqual(path.basename(file, ".js"), "path.test");