Remove url npm dependency and use Web URL constructor (#10930)

This commit is contained in:
Michael Telatynski 2023-05-17 12:50:00 +01:00 committed by GitHub
parent 7917d973e7
commit 2da199c41d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 101 additions and 53 deletions

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import url from "url";
import { ComponentProps } from "react";
import { logger } from "matrix-js-sdk/src/logger";
@ -25,6 +24,7 @@ import Modal from "../Modal";
import SettingsStore from "../settings/SettingsStore";
import IntegrationManager from "../components/views/settings/IntegrationManager";
import { IntegrationManagers } from "./IntegrationManagers";
import { parseUrl } from "../utils/UrlUtils";
export enum Kind {
Account = "account",
@ -42,15 +42,14 @@ export class IntegrationManagerInstance {
) {}
public get name(): string {
const parsed = url.parse(this.uiUrl);
const parsed = parseUrl(this.uiUrl);
return parsed.host ?? "";
}
public get trimmedApiUrl(): string {
const parsed = url.parse(this.apiUrl);
const parsed = parseUrl(this.apiUrl);
parsed.pathname = "";
parsed.path = "";
return url.format(parsed);
return parsed.toString();
}
public getScalarClient(): ScalarAuthClient {

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import url from "url";
import { logger } from "matrix-js-sdk/src/logger";
import { ClientEvent, IClientWellKnown, MatrixClient } from "matrix-js-sdk/src/client";
import { compare } from "matrix-js-sdk/src/utils";
@ -27,6 +26,7 @@ import IntegrationsImpossibleDialog from "../components/views/dialogs/Integratio
import IntegrationsDisabledDialog from "../components/views/dialogs/IntegrationsDisabledDialog";
import WidgetUtils from "../utils/WidgetUtils";
import { MatrixClientPeg } from "../MatrixClientPeg";
import { parseUrl } from "../utils/UrlUtils";
const KIND_PREFERENCE = [
// Ordered: first is most preferred, last is least preferred.
@ -199,7 +199,7 @@ export class IntegrationManagers {
logger.log("Looking up integration manager via .well-known");
if (domainName.startsWith("http:") || domainName.startsWith("https:")) {
// trim off the scheme and just use the domain
domainName = url.parse(domainName).host!;
domainName = parseUrl(domainName).host;
}
let wkConfig: IClientWellKnown;