diff --git a/app/mm-redux/client/client4.test.js b/app/mm-redux/client/client4.test.js index b11671338..c52bad7ac 100644 --- a/app/mm-redux/client/client4.test.js +++ b/app/mm-redux/client/client4.test.js @@ -19,6 +19,16 @@ describe('Client4', () => { nock.restore(); }); + it('should remove trailing slash while trying to setUrl', () => { + const client = TestHelper.createClient(); + + client.setUrl('http://localhost:8065/'); + expect(client.url).toBe('http://localhost:8065'); + + client.setUrl('http://localhost:8065/company/mattermost/'); + expect(client.url).toBe('http://localhost:8065/company/mattermost'); + }); + describe('doFetchWithResponse', () => { it('serverVersion should be set from response header', async () => { const client = TestHelper.createClient(); diff --git a/app/mm-redux/client/client4.ts b/app/mm-redux/client/client4.ts index 9931c9db8..e8aa71dc0 100644 --- a/app/mm-redux/client/client4.ts +++ b/app/mm-redux/client/client4.ts @@ -68,7 +68,7 @@ export default class Client4 { } setUrl(url: string) { - this.url = url; + this.url = url.replace(/\/+$/, ''); } setUserAgent(userAgent: string) {