refactor: remove deprecated url.parse() method (#7751)

This commit is contained in:
Corey
2022-01-06 09:26:00 -05:00
committed by GitHub
parent a43638f300
commit a5ffb95022
9 changed files with 74 additions and 36 deletions

View File

@@ -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 + '=' + '********' + '&';