Skip to content

Commit

Permalink
chore: remove leading slash from provided endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MoumitaM committed May 21, 2024
1 parent b7c464c commit 3492300
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ describe('Config manager util - validate load arguments', () => {
});
describe('getDataServiceUrl', () => {
it('should return dataServiceUrl', () => {
const dataServiceUrl = getDataServiceUrl('rsaRequest');
expect(dataServiceUrl).toBe('http://test-host.com/rsaRequest');
const dataServiceUrl = getDataServiceUrl('endpoint');
expect(dataServiceUrl).toBe('http://test-host.com/endpoint');
});
it('should prepare the dataServiceUrl with endpoint without leading slash', () => {
const dataServiceUrl = getDataServiceUrl('/endpoint');
expect(dataServiceUrl).toBe('http://test-host.com/endpoint');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ const getTopDomainUrl = (url: string) => {

const getDataServiceUrl = (endpoint: string) => {
const url = getTopDomainUrl(window.location.href);
return `${url}/${endpoint}`;
const formattedEndpoint = endpoint.startsWith('/') ? endpoint.substring(1) : endpoint;
return `${url}/${formattedEndpoint}`;
};

export {
Expand Down

0 comments on commit 3492300

Please sign in to comment.