Minify: Replace deprecated `url.parse()` with `new URL()`

pull/4765/head
Richard Hansen 2021-02-11 19:44:43 -05:00 committed by John McLear
parent 7efca7dc7d
commit 73d31b12a8
1 changed files with 2 additions and 3 deletions

View File

@ -26,7 +26,6 @@ const fs = require('fs').promises;
const path = require('path'); const path = require('path');
const plugins = require('../../static/js/pluginfw/plugin_defs'); const plugins = require('../../static/js/pluginfw/plugin_defs');
const RequireKernel = require('etherpad-require-kernel'); const RequireKernel = require('etherpad-require-kernel');
const urlutil = require('url');
const mime = require('mime-types'); const mime = require('mime-types');
const Threads = require('threads'); const Threads = require('threads');
const log4js = require('log4js'); const log4js = require('log4js');
@ -49,13 +48,13 @@ const LIBRARY_WHITELIST = [
// What follows is a terrible hack to avoid loop-back within the server. // What follows is a terrible hack to avoid loop-back within the server.
// TODO: Serve files from another service, or directly from the file system. // TODO: Serve files from another service, or directly from the file system.
const requestURI = async (url, method, headers) => await new Promise((resolve, reject) => { const requestURI = async (url, method, headers) => await new Promise((resolve, reject) => {
const parsedURL = urlutil.parse(url); const parsedUrl = new URL(url);
let status = 500; let status = 500;
const content = []; const content = [];
const mockRequest = { const mockRequest = {
url, url,
method, method,
params: {filename: parsedURL.path.replace(/^\/static\//, '')}, params: {filename: (parsedUrl.pathname + parsedUrl.search).replace(/^\/static\//, '')},
headers, headers,
}; };
const mockResponse = { const mockResponse = {