const escapeStringRegexp = require('escape-string-regexp'); module.exports = (str, suffix) => { if (!str) return str; if (!suffix) return str; const re = new RegExp(`${escapeStringRegexp(suffix)}$`); return str.replace(re, ''); };