Set url trailing slash (#5322)

This commit is contained in:
Anurag Shivarathri 2021-04-15 01:46:25 +05:30 committed by GitHub
parent e0c45b86b4
commit 812902dbe1
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) {