open-consul/ui-v2/app/utils/right-trim.js
2018-06-12 11:24:35 +01:00

5 lines
172 B
JavaScript

export default function rightTrim(str = '', search = '') {
const pos = str.length - search.length;
return str.lastIndexOf(search) === pos ? str.substr(0, pos) : str;
}