This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/strip-outer/index.js
2020-11-01 22:46:04 +00:00

12 lines
306 B
JavaScript

'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'), '');
};