mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
20 lines
467 B
TypeScript
20 lines
467 B
TypeScript
|
export const formatBaseUri = (input: string): string => {
|
||
|
if (!input) return '';
|
||
|
const firstChar = input[0];
|
||
|
const lastChar = input[input.length - 1];
|
||
|
|
||
|
if (firstChar === '/' && lastChar === '/') {
|
||
|
return input.substr(0, input.length - 1);
|
||
|
}
|
||
|
|
||
|
if (firstChar !== '/' && lastChar === '/') {
|
||
|
return `/${input.substr(0, input.length - 1)}`;
|
||
|
}
|
||
|
|
||
|
if (firstChar !== '/') {
|
||
|
return `/${input}`;
|
||
|
}
|
||
|
|
||
|
return input;
|
||
|
};
|