system_assignation/node_modules/strip-outer/index.js

12 lines
306 B
JavaScript
Raw Permalink Normal View History

2022-03-24 09:22:39 -04:00
'use strict';
var escapeStringRegexp = require('escape-string-regexp');
module.exports = function (str, sub) {
if (typeof str !== 'string' || typeof sub !== 'string') {
throw new TypeError();
}
sub = escapeStringRegexp(sub);
return str.replace(new RegExp('^' + sub + '|' + sub + '$', 'g'), '');
};