Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-54465] Remove lowercase call when checking path names #2831

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, '/');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any cases where later we compare the server url that it make break now if it's there any casing mistmatch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be. We were doing this to make sure the path name was lower case, and this function is mostly to get rid of double slashes. We do a lower case when we compared host and origin in other parts of the code.

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
Loading