open-consul/ui-v2/app/utils/right-trim.js

5 lines
172 B
JavaScript
Raw Normal View History

2018-05-25 12:15:27 +00:00
export default function rightTrim(str = '', search = '') {
const pos = str.length - search.length;
return str.lastIndexOf(search) === pos ? str.substr(0, pos) : str;
}