2015-07-10 14:37:13 +01:00
|
|
|
/*
|
2026-03-12 15:54:01 +00:00
|
|
|
Copyright 2026 Element Creations Ltd.
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2019-09-30 20:17:54 -06:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2015-07-10 14:37:13 +01:00
|
|
|
|
2025-01-06 11:18:54 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-09 14:57:16 +01:00
|
|
|
Please see LICENSE files in the repository root for full details.
|
2015-07-10 14:37:13 +01:00
|
|
|
*/
|
|
|
|
|
|
2022-08-09 12:55:49 +01:00
|
|
|
const escapeRegExp = function (s: string): string {
|
|
|
|
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
2016-03-20 12:31:30 +00:00
|
|
|
};
|
|
|
|
|
|
2020-12-21 12:46:29 +00:00
|
|
|
// Recognise URLs from both our local and official Element deployments.
|
2022-02-03 08:55:49 +00:00
|
|
|
// Anyone else really should be using matrix.to. vector:// allowed to support Element Desktop relative links.
|
2026-03-12 15:54:01 +00:00
|
|
|
export const ELEMENT_URL_PATTERN = new RegExp(
|
2022-02-03 08:55:49 +00:00
|
|
|
"^(?:vector://|https?://)?(?:" +
|
2026-03-12 15:54:01 +00:00
|
|
|
escapeRegExp(window.location.host + window.location.pathname) +
|
|
|
|
|
"|" +
|
|
|
|
|
"(?:www\\.)?(?:riot|vector)\\.im/(?:app|beta|staging|develop)/|" +
|
|
|
|
|
"(?:app|beta|staging|develop)\\.element\\.io/" +
|
|
|
|
|
")(#.*)",
|
|
|
|
|
);
|