Skip to content

Commit

Permalink
[MM-54465] Remove lowercase call when checking path names (#2831) (#2834
Browse files Browse the repository at this point in the history
)

(cherry picked from commit 128d15a)

Co-authored-by: Devin Binnie <[email protected]>
  • Loading branch information
mattermost-build and devinbinnie authored Sep 15, 2023
1 parent 4f266a3 commit e0f3493
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/common/Validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export function validateV0ConfigData(data: ConfigV0) {
function cleanURL(url: string): string {
let updatedURL = url;
if (updatedURL.includes('\\')) {
updatedURL = updatedURL.toLowerCase().replace(/\\/gi, '/');
updatedURL = updatedURL.replace(/\\/gi, '/');
}
return updatedURL;
}
Expand Down
7 changes: 1 addition & 6 deletions src/common/utils/url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ jest.mock('common/views/View', () => ({

describe('common/utils/url', () => {
describe('getFormattedPathName', () => {
it('should format all to lower case', () => {
const unformattedPathName = '/aAbBbB/cC/DdeR/';
expect(getFormattedPathName(unformattedPathName)).toBe('/aabbbb/cc/dder/');
});

it('should add trailing slash', () => {
const unformattedPathName = '/aAbBbB/cC/DdeR';
expect(getFormattedPathName(unformattedPathName)).toBe('/aabbbb/cc/dder/');
expect(getFormattedPathName(unformattedPathName)).toBe('/aAbBbB/cC/DdeR/');
});
});
describe('parseURL', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {isHttpsUri, isHttpUri, isUri} from 'valid-url';
import buildConfig from 'common/config/buildConfig';
import {customLoginRegexPaths, nonTeamUrlPaths, CALLS_PLUGIN_ID} from 'common/utils/constants';

export const getFormattedPathName = (pn: string) => (pn.endsWith('/') ? pn.toLowerCase() : `${pn.toLowerCase()}/`);
export const getFormattedPathName = (pn: string) => (pn.endsWith('/') ? pn : `${pn}/`);
export const parseURL = (inputURL: string | URL) => {
if (inputURL instanceof URL) {
return inputURL;
Expand Down
2 changes: 1 addition & 1 deletion src/main/windows/callsWidgetWindow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ describe('main/windows/callsWidgetWindow', () => {
beforeEach(() => {
urlUtils.parseURL.mockImplementation((url) => new URL(url));
urlUtils.getFormattedPathName.mockImplementation((pn) => {
return pn.endsWith('/') ? pn.toLowerCase() : `${pn.toLowerCase()}/`;
return pn.endsWith('/') ? pn : `${pn}/`;
});
callsWidgetWindow.options = {
callID: 'test-call-id',
Expand Down

0 comments on commit e0f3493

Please sign in to comment.