Sha256: 1a19ed5c1a4dad0bd70a6fee0a2421d72c6df6a452735798aa37f51252f9bbf0

Contents?: true

Size: 1.77 KB

Versions: 42

Compression:

Stored size: 1.77 KB

Contents

# remove-trailing-separator

[![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]

Removes all separators from the end of a string.

## Install

```
npm install remove-trailing-separator
```

## Examples

```js
const removeTrailingSeparator = require('remove-trailing-separator');

removeTrailingSeparator('/foo/bar/')   // '/foo/bar'
removeTrailingSeparator('/foo/bar///') // '/foo/bar'

// leaves only/last separator
removeTrailingSeparator('/')    // '/'
removeTrailingSeparator('///')  // '/'

// returns empty string
removeTrailingSeparator('') // ''
```

## Notable backslash, or win32 separator behavior

`\` is considered a separator only on WIN32 systems. All POSIX compliant systems
see backslash as a valid file name character, so it would break POSIX compliance
to remove it there.

In practice, this means that this code will return different things depending on
what system it runs on:

```js
removeTrailingSeparator('\\foo\\')
// UNIX  => '\\foo\\'
// WIN32 => '\\foo'
```

[npm-url]: https://npmjs.org/package/remove-trailing-separator
[npm-img]: https://badge.fury.io/js/remove-trailing-separator.svg
[travis-url]: https://travis-ci.org/darsain/remove-trailing-separator
[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

Version data entries

42 entries across 41 versions & 15 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/remove-trailing-separator/readme.md
disco_app-0.18.0 test/dummy/node_modules/remove-trailing-separator/readme.md
disco_app-0.18.2 test/dummy/node_modules/remove-trailing-separator/readme.md
disco_app-0.16.1 test/dummy/node_modules/remove-trailing-separator/readme.md
disco_app-0.15.2 test/dummy/node_modules/remove-trailing-separator/readme.md
disco_app-0.18.4 test/dummy/node_modules/remove-trailing-separator/readme.md
disco_app-0.18.1 test/dummy/node_modules/remove-trailing-separator/readme.md
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/remove-trailing-separator/readme.md
disco_app-0.14.0 test/dummy/node_modules/remove-trailing-separator/readme.md
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/remove-trailing-separator/readme.md
tang-0.2.1 spec/tang_app/node_modules/remove-trailing-separator/readme.md
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/remove-trailing-separator/readme.md
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/remove-trailing-separator/readme.md
ruby2js-4.0.4 lib/tasks/testrails/node_modules/remove-trailing-separator/readme.md
ruby2js-4.0.3 lib/tasks/testrails/node_modules/remove-trailing-separator/readme.md
tang-0.2.0 spec/tang_app/node_modules/remove-trailing-separator/readme.md
tang-0.1.0 spec/tang_app/node_modules/remove-trailing-separator/readme.md
tang-0.0.9 spec/tang_app/node_modules/remove-trailing-separator/readme.md
enju_library-0.3.8 spec/dummy/node_modules/remove-trailing-separator/readme.md
ilog-0.4.1 node_modules/remove-trailing-separator/readme.md