Socket
Socket
Sign inDemoInstall

remove-trailing-separator

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.1.0

4

history.md
## History
### 1.1.0 - 16th Aug 2017
- [f4576e3](https://github.com/darsain/remove-trailing-separator/commit/f4576e3638c39b794998b533fffb27854dcbee01) Implement faster slash slicing
### 1.0.2 - 07th Jun 2017

@@ -4,0 +8,0 @@

16

index.js
var isWin = process.platform === 'win32';
module.exports = function (str) {
while (endsInSeparator(str)) {
str = str.slice(0, -1);
var i = str.length - 1;
if (i < 2) {
return str;
}
return str;
while (isSeparator(str, i)) {
i--;
}
return str.substr(0, i + 1);
};
function endsInSeparator(str) {
var last = str[str.length - 1];
return str.length > 1 && (last === '/' || (isWin && last === '\\'));
function isSeparator(str, i) {
var char = str[i];
return i > 0 && (char === '/' || (isWin && char === '\\'));
}
{
"name": "remove-trailing-separator",
"version": "1.0.2",
"version": "1.1.0",
"description": "Removes separators from the end of the string.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -29,3 +29,3 @@ # remove-trailing-separator

## Backslash, or win32 separator
## Notable backslash, or win32 separator behavior

@@ -39,3 +39,3 @@ `\` is considered a separator only on WIN32 systems. All POSIX compliant systems

```
```js
removeTrailingSeparator('\\foo\\')

@@ -42,0 +42,0 @@ // UNIX => '\\foo\\'

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc