[MM-52587] Clean up URL utils, use isInternalURL when possible (#2702)

This commit is contained in:
Devin Binnie
2023-05-03 08:48:41 -04:00
committed by GitHub
parent f3a4417464
commit e227c6bf1d
30 changed files with 481 additions and 634 deletions

View File

@@ -15,8 +15,8 @@ import {app, BrowserWindow} from 'electron';
import {Args} from 'types/args';
import {BACK_BAR_HEIGHT, customLoginRegexPaths, PRODUCTION, TAB_BAR_HEIGHT} from 'common/utils/constants';
import UrlUtils from 'common/utils/url';
import Utils from 'common/utils/util';
import {isAdminUrl, isPluginUrl, isTeamUrl, isUrlType, parseURL} from 'common/utils/url';
export function isInsideRectangle(container: Electron.Rectangle, rect: Electron.Rectangle) {
return container.x <= rect.x && container.y <= rect.y && container.width >= rect.width && container.height >= rect.height;
@@ -48,11 +48,11 @@ export function getAdjustedWindowBoundaries(width: number, height: number, hasBa
};
}
export function shouldHaveBackBar(serverUrl: URL | string, inputURL: URL | string) {
if (UrlUtils.isUrlType('login', serverUrl, inputURL)) {
const serverURL = UrlUtils.parseURL(serverUrl);
export function shouldHaveBackBar(serverUrl: URL, inputURL: URL) {
if (isUrlType('login', serverUrl, inputURL)) {
const serverURL = parseURL(serverUrl);
const subpath = serverURL ? serverURL.pathname : '';
const parsedURL = UrlUtils.parseURL(inputURL);
const parsedURL = parseURL(inputURL);
if (!parsedURL) {
return false;
}
@@ -67,7 +67,7 @@ export function shouldHaveBackBar(serverUrl: URL | string, inputURL: URL | strin
return false;
}
return !UrlUtils.isTeamUrl(serverUrl, inputURL) && !UrlUtils.isAdminUrl(serverUrl, inputURL) && !UrlUtils.isPluginUrl(serverUrl, inputURL);
return !isTeamUrl(serverUrl, inputURL) && !isAdminUrl(serverUrl, inputURL) && !isPluginUrl(serverUrl, inputURL);
}
export function getLocalURLString(urlPath: string, query?: Map<string, string>, isMain?: boolean) {