blob: 497186a7d1df794294848c0fcaa6de2864f3dbcc [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2var escapeStringRegexp = require('escape-string-regexp');
3
4module.exports = function (str, sub) {
5 if (typeof str !== 'string' || typeof sub !== 'string') {
6 throw new TypeError();
7 }
8
9 sub = escapeStringRegexp(sub);
10 return str.replace(new RegExp('^' + sub + '|' + sub + '$', 'g'), '');
11};