remove-trailing-separator
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -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 |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3862
5
11
51
0