From 0adf3618e29355c947bf8af5519ce47849c5cf7a Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Wed, 14 Apr 2021 22:48:36 +0200 Subject: [PATCH] Set url trailing slash (#5322) (#5323) --- app/mm-redux/client/client4.test.js | 10 ++++++++++ app/mm-redux/client/client4.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) 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) {