mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
85a544bbd6
* chore: update changelog * feat: add formatBaseUri helper * feat: call formatBaseUri on server options * feat: call formatBaseUri on user options * fix: update test * fix: disable consistent return
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;
|
|
};
|