aboutsummaryrefslogtreecommitdiff
path: root/node_modules/strip-outer/index.js
blob: 497186a7d1df794294848c0fcaa6de2864f3dbcc (plain)
1
2
3
4
5
6
7
8
9
10
11
'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'), '');
};