2018-11-28 16:35:55 +00:00
|
|
|
// will trim a given set of endings from the end of a string
|
|
|
|
// if isExtension is true, the first char of that string will be escaped
|
|
|
|
// in the regex
|
|
|
|
export default function(str, endings = [], isExtension = true) {
|
|
|
|
let prefix = isExtension ? '\\' : '';
|
|
|
|
let trimRegex = new RegExp(endings.map(ext => `${prefix}${ext}$`).join('|'));
|
|
|
|
return str.replace(trimRegex, '');
|
2018-06-14 04:06:19 +00:00
|
|
|
}
|