From c48ebbe2025f5852d9d75625d761f87d83e455a9 Mon Sep 17 00:00:00 2001 From: liwei Date: Fri, 16 Aug 2024 14:50:09 +0800 Subject: [PATCH] fix: url fileURLToPath polyfill --- modules/http/index.js | 2 +- modules/url/index.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/http/index.js b/modules/http/index.js index 6317e11..66007f3 100644 --- a/modules/http/index.js +++ b/modules/http/index.js @@ -2,7 +2,7 @@ var ClientRequest = require("./lib/request"); var response = require("./lib/response"); var extend = require("xtend"); var statusCodes = require("builtin-status-codes"); -var url = require("url"); +var url = require("url/"); var http = exports; diff --git a/modules/url/index.js b/modules/url/index.js index c4706db..95ae2aa 100644 --- a/modules/url/index.js +++ b/modules/url/index.js @@ -22,7 +22,7 @@ function getPathFromURLPosix(url) { return decodeURIComponent(pathname); } -function fileURLToPath(path) { +url.fileURLToPath = function (path) { if (typeof path === "string") { path = url.parse(path); } else if (!isURLInstance(path)) { @@ -35,6 +35,6 @@ function fileURLToPath(path) { throw new TypeError("The URL must be of scheme file"); } return getPathFromURLPosix(path); -} +}; -module.exports = { ...url, fileURLToPath }; +module.exports = url;