mirror of
https://github.com/strapi/strapi.git
synced 2025-11-07 05:38:13 +00:00
fixed getRequestUrl and added tests
This commit is contained in:
parent
0d05858ea1
commit
a93e5e9119
@ -1,5 +1,11 @@
|
|||||||
import pluginId from '../pluginId';
|
import pluginId from '../pluginId';
|
||||||
|
|
||||||
const getRequestUrl = path => `/${pluginId}/${path}`;
|
const getRequestUrl = path => {
|
||||||
|
if (path.startsWith('/')) {
|
||||||
|
return `/${pluginId}${path}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `/${pluginId}/${path}`;
|
||||||
|
};
|
||||||
|
|
||||||
export default getRequestUrl;
|
export default getRequestUrl;
|
||||||
|
|||||||
@ -0,0 +1,17 @@
|
|||||||
|
import getRequestUrl from '../getRequestUrl';
|
||||||
|
|
||||||
|
describe('upload || utils || getRequestUrl', () => {
|
||||||
|
test('return right format url if argument starts with /', () => {
|
||||||
|
const result = getRequestUrl('/test');
|
||||||
|
const expected = '/upload/test';
|
||||||
|
|
||||||
|
expect(result).toEqual(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return right format url if argument does not start with /', () => {
|
||||||
|
const result = getRequestUrl('test');
|
||||||
|
const expected = '/upload/test';
|
||||||
|
|
||||||
|
expect(result).toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user