mirror of
https://github.com/tenrok/axios.git
synced 2026-05-18 12:39:44 +03:00
fe7d09bb08
* Fixing combineURLs to support an empty relativeURL When combining the base and relative URLs, we should forego force appending a slash to the base when the relative URL is empty. This leads to a semantic url. * Fixing combineURLs, allowing single slash relatives
24 lines
932 B
JavaScript
24 lines
932 B
JavaScript
var combineURLs = require('../../../lib/helpers/combineURLs');
|
|
|
|
describe('helpers::combineURLs', function () {
|
|
it('should combine URLs', function () {
|
|
expect(combineURLs('https://api.github.com', '/users')).toBe('https://api.github.com/users');
|
|
});
|
|
|
|
it('should remove duplicate slashes', function () {
|
|
expect(combineURLs('https://api.github.com/', '/users')).toBe('https://api.github.com/users');
|
|
});
|
|
|
|
it('should insert missing slash', function () {
|
|
expect(combineURLs('https://api.github.com', 'users')).toBe('https://api.github.com/users');
|
|
});
|
|
|
|
it('should not insert slash when relative url missing/empty', function () {
|
|
expect(combineURLs('https://api.github.com/users', '')).toBe('https://api.github.com/users');
|
|
});
|
|
|
|
it('should allow a single slash for relative url', function () {
|
|
expect(combineURLs('https://api.github.com/users', '/')).toBe('https://api.github.com/users/');
|
|
});
|
|
});
|