mirror of https://github.com/hashicorp/consul
8 lines
210 B
JavaScript
8 lines
210 B
JavaScript
|
export default function rightTrim(str = '', search = '') {
|
||
|
const pos = str.length - search.length;
|
||
|
if (pos >= 0) {
|
||
|
return str.lastIndexOf(search) === pos ? str.substr(0, pos) : str;
|
||
|
}
|
||
|
return str;
|
||
|
}
|