Remove url
npm dependency and use Web URL constructor (#10930)
This commit is contained in:
parent
7917d973e7
commit
2da199c41d
13 changed files with 101 additions and 53 deletions
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue