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.0 to 1.0.1

history.md

4

index.js

@@ -0,1 +1,3 @@

const isWin = process.platform === 'win32';
module.exports = function (str) {

@@ -10,3 +12,3 @@ while (endsInSeparator(str)) {

var last = str[str.length - 1];
return str.length > 1 && (last === '/' || last === '\\');
return str.length > 1 && (last === '/' || (isWin && last === '\\'));
}
{
"name": "remove-trailing-separator",
"version": "1.0.0",
"version": "1.0.1",
"description": "Removes separators from the end of the string.",

@@ -22,2 +22,3 @@ "main": "index.js",

"strip",
"trailing",
"separator"

@@ -24,0 +25,0 @@ ],

# remove-trailing-separator
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url]
[![NPM version][npm-img]][npm-url] [![Build Status: Linux][travis-img]][travis-url] [![Build Status: Windows][appveyor-img]][appveyor-url] [![Coverage Status][coveralls-img]][coveralls-url]

@@ -27,16 +27,26 @@ Removes all separators from the end of a string.

removeTrailingSeparator('') // ''
```
// same as above for win32 separators
removeTrailingSeparator('\\foo\\bar\\') // '\\foo\\bar'
removeTrailingSeparator('\\foo\\bar\\\\\\') // '\\foo\\bar'
removeTrailingSeparator('\\') // '\\'
removeTrailingSeparator('\\\\\\') // '\\'
removeTrailingSeparator('') // ''
## Backslash, or win32 separator
`\` is considered a separator only on WIN32 systems. All UNIX compliant systems
see backslash as a valid file name character, so it would break UNIX compliance
to remove it there.
In practice, this means that this code will return different things depending on
what system it runs on:
```
removeTrailingSeparator('\\foo\\')
// UNIX => '\\foo\\'
// WIN32 => '\\foo'
```
[npm-url]: https://npmjs.org/package/remove-trailing-separator
[npm-image]: https://badge.fury.io/js/remove-trailing-separator.svg
[npm-img]: https://badge.fury.io/js/remove-trailing-separator.svg
[travis-url]: https://travis-ci.org/darsain/remove-trailing-separator
[travis-image]: https://travis-ci.org/darsain/remove-trailing-separator.svg?branch=master
[coveralls-url]: https://coveralls.io/github/darsain/remove-trailing-separator
[coveralls-image]: https://coveralls.io/repos/github/darsain/remove-trailing-separator/badge.svg
[travis-img]: https://travis-ci.org/darsain/remove-trailing-separator.svg?branch=master
[appveyor-url]: https://ci.appveyor.com/project/darsain/remove-trailing-separator/branch/master
[appveyor-img]: https://ci.appveyor.com/api/projects/status/wvg9a93rrq95n2xl/branch/master?svg=true
[coveralls-url]: https://coveralls.io/github/darsain/remove-trailing-separator?branch=master
[coveralls-img]: https://coveralls.io/repos/github/darsain/remove-trailing-separator/badge.svg?branch=master
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