Set url trailing slash (#5322) (#5323)

This commit is contained in:
Mattermost Build 2021-04-14 22:48:36 +02:00 committed by GitHub
parent c3569e27a9
commit 0adf3618e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -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();

View file

@ -68,7 +68,7 @@ export default class Client4 {
}
setUrl(url: string) {
this.url = url;
this.url = url.replace(/\/+$/, '');
}
setUserAgent(userAgent: string) {