From 078d6a0d98d2890828c984addce4f3fc7e2b1124 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 13 Apr 2020 21:36:49 +0100 Subject: [PATCH] remove dependency on `url` Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- package.json | 3 +-- src/vector/app.js | 9 +++------ src/vector/platform/WebPlatform.js | 7 +++---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index de533bc54..0b83a69f9 100644 --- a/package.json +++ b/package.json @@ -76,8 +76,7 @@ "react": "^16.9.0", "react-dom": "^16.9.0", "sanitize-html": "^1.19.1", - "ua-parser-js": "^0.7.19", - "url": "^0.11.0" + "ua-parser-js": "^0.7.19" }, "devDependencies": { "@babel/cli": "^7.7.5", diff --git a/src/vector/app.js b/src/vector/app.js index 930576e2d..e087d8c2f 100644 --- a/src/vector/app.js +++ b/src/vector/app.js @@ -31,8 +31,6 @@ import AutoDiscoveryUtils from 'matrix-react-sdk/src/utils/AutoDiscoveryUtils'; import {AutoDiscovery} from "matrix-js-sdk/src/autodiscovery"; import * as Lifecycle from "matrix-react-sdk/src/Lifecycle"; -import url from 'url'; - import {parseQs, parseQsFromFragment} from './url_utils'; import {MatrixClientPeg} from 'matrix-react-sdk/src/MatrixClientPeg'; @@ -118,11 +116,10 @@ function onTokenLoginCompleted() { // if we did a token login, we're now left with the token, hs and is // url as query params in the url; a little nasty but let's redirect to // clear them. - const parsedUrl = url.parse(window.location.href); + const parsedUrl = new URL(window.location); parsedUrl.search = ""; - const formatted = url.format(parsedUrl); - console.log("Redirecting to " + formatted + " to drop loginToken " + - "from queryparams"); + const formatted = parsedUrl.toString(); + console.log("Redirecting to " + formatted + " to drop loginToken from queryparams"); window.location.href = formatted; } diff --git a/src/vector/platform/WebPlatform.js b/src/vector/platform/WebPlatform.js index 8db12856f..4524d720c 100644 --- a/src/vector/platform/WebPlatform.js +++ b/src/vector/platform/WebPlatform.js @@ -22,7 +22,6 @@ import request from 'browser-request'; import dis from 'matrix-react-sdk/src/dispatcher.js'; import { _t } from 'matrix-react-sdk/src/languageHandler'; -import url from 'url'; import UAParser from 'ua-parser-js'; const POKE_RATE_MS = 10 * 60 * 1000; // 10 min @@ -179,15 +178,15 @@ export default class WebPlatform extends VectorBasePlatform { getDefaultDeviceDisplayName(): string { // strip query-string and fragment from uri - const u = url.parse(window.location.href); + const u = new URL(window.location); u.search = ""; u.hash = ""; - const appName = u.format(); + const appName = u.toString(); const ua = new UAParser(); const browserName = ua.getBrowser().name || "unknown browser"; const osName = ua.getOS().name || "unknown os"; - return _t('%(appName)s via %(browserName)s on %(osName)s', {appName: appName, browserName: browserName, osName: osName}); + return _t('%(appName)s via %(browserName)s on %(osName)s', {appName, browserName, osName}); } screenCaptureErrorString(): ?string {