Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

strip-outer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strip-outer - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

20

index.js

@@ -1,11 +0,15 @@

'use strict';
var escapeStringRegexp = require('escape-string-regexp');
export default function stripOuter(string, substring) {
if (typeof string !== 'string' || typeof substring !== 'string') {
throw new TypeError('Expected a string');
}
module.exports = function (str, sub) {
if (typeof str !== 'string' || typeof sub !== 'string') {
throw new TypeError();
if (string.startsWith(substring)) {
string = string.slice(substring.length);
}
sub = escapeStringRegexp(sub);
return str.replace(new RegExp('^' + sub + '|' + sub + '$', 'g'), '');
};
if (string.endsWith(substring)) {
string = string.slice(0, -substring.length);
}
return string;
}

81

package.json
{
"name": "strip-outer",
"version": "1.0.1",
"description": "Strip a substring from the start/end of a string",
"license": "MIT",
"repository": "sindresorhus/strip-outer",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"strip",
"trim",
"remove",
"outer",
"str",
"string",
"substring",
"start",
"end",
"wrap",
"leading",
"trailing",
"regex",
"regexp"
],
"dependencies": {
"escape-string-regexp": "^1.0.2"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "strip-outer",
"version": "2.0.0",
"description": "Strip a substring from the start/end of a string",
"license": "MIT",
"repository": "sindresorhus/strip-outer",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"strip",
"trim",
"remove",
"outer",
"string",
"substring",
"start",
"end",
"wrap",
"leading",
"trailing"
],
"devDependencies": {
"ava": "^3.15.0",
"xo": "^0.44.0"
}
}

@@ -1,17 +0,15 @@

# strip-outer [![Build Status](https://travis-ci.org/sindresorhus/strip-outer.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-outer)
# strip-outer
> Strip a substring from the start/end of a string
## Install
```
$ npm install --save strip-outer
$ npm install strip-outer
```
## Usage
```js
const stripOuter = require('strip-outer');
import stripOuter from 'strip-outer';

@@ -24,6 +22,1 @@ stripOuter('foobarfoo', 'foo');

```
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc