refactor: remove deprecated url.parse() method (#7751)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { Parse } from 'parse/node';
|
||||
import AdaptableController from './AdaptableController';
|
||||
import { LoggerAdapter } from '../Adapters/Logger/LoggerAdapter';
|
||||
import url from 'url';
|
||||
|
||||
const MILLISECONDS_IN_A_DAY = 24 * 60 * 60 * 1000;
|
||||
const LOG_STRING_TRUNCATE_LENGTH = 1000;
|
||||
@@ -38,15 +37,16 @@ export class LoggerController extends AdaptableController {
|
||||
});
|
||||
}
|
||||
|
||||
maskSensitiveUrl(urlString) {
|
||||
const urlObj = url.parse(urlString, true);
|
||||
const query = urlObj.query;
|
||||
maskSensitiveUrl(path) {
|
||||
const urlString = 'http://localhost' + path; // prepend dummy string to make a real URL
|
||||
const urlObj = new URL(urlString);
|
||||
const query = urlObj.searchParams;
|
||||
let sanitizedQuery = '?';
|
||||
|
||||
for (const key in query) {
|
||||
for (const [key, value] of query) {
|
||||
if (key !== 'password') {
|
||||
// normal value
|
||||
sanitizedQuery += key + '=' + query[key] + '&';
|
||||
sanitizedQuery += key + '=' + value + '&';
|
||||
} else {
|
||||
// password value, redact it
|
||||
sanitizedQuery += key + '=' + '********' + '&';
|
||||
|
||||
@@ -2,7 +2,6 @@ import authDataManager from '../Adapters/Auth';
|
||||
import { ParseServerOptions } from '../Options';
|
||||
import { loadAdapter } from '../Adapters/AdapterLoader';
|
||||
import defaults from '../defaults';
|
||||
import url from 'url';
|
||||
// Controllers
|
||||
import { LoggerController } from './LoggerController';
|
||||
import { FilesController } from './FilesController';
|
||||
@@ -220,7 +219,7 @@ export function getAuthDataManager(options: ParseServerOptions) {
|
||||
export function getDatabaseAdapter(databaseURI, collectionPrefix, databaseOptions) {
|
||||
let protocol;
|
||||
try {
|
||||
const parsedURI = url.parse(databaseURI);
|
||||
const parsedURI = new URL(databaseURI);
|
||||
protocol = parsedURI.protocol ? parsedURI.protocol.toLowerCase() : null;
|
||||
} catch (e) {
|
||||
/* */
|
||||
|
||||
Reference in New Issue
Block a user