pax_global_header00006660000000000000000000000064127717205410014520gustar00rootroot0000000000000052 comment=8a5da3ac1efb1314d55e50a2a923b068d500d77a remove-trailing-separator-1.0.1/000077500000000000000000000000001277172054100166215ustar00rootroot00000000000000remove-trailing-separator-1.0.1/.gitignore000066400000000000000000000000701277172054100206060ustar00rootroot00000000000000.DS_Store *.log *.node node_modules coverage .nyc_outputremove-trailing-separator-1.0.1/.travis.yml000066400000000000000000000003771277172054100207410ustar00rootroot00000000000000language: node_js node_js: - '6' - '5' - '4' - '0.12' - '0.10' before_install: - 'npm install -g npm@latest' after_success: - './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' notifications: email: falseremove-trailing-separator-1.0.1/appveyor.yml000066400000000000000000000004651277172054100212160ustar00rootroot00000000000000environment: matrix: - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "4" - nodejs_version: "5" - nodejs_version: "6" install: - ps: Install-Product node $env:nodejs_version - npm install test_script: - node --version - npm --version - npm test build: offremove-trailing-separator-1.0.1/history.md000066400000000000000000000003541277172054100206460ustar00rootroot00000000000000## History ### 1.0.1 - 25th Sep 2016 - [b78606d](https://github.com/darsain/remove-trailing-separator/commit/af90b4e153a4527894741af6c7005acaeb78606d) Remove backslash only on win32 systems ### 1.0.0 - 24th Sep 2016 Initial release.remove-trailing-separator-1.0.1/index.js000066400000000000000000000004461277172054100202720ustar00rootroot00000000000000const isWin = process.platform === 'win32'; module.exports = function (str) { while (endsInSeparator(str)) { str = str.slice(0, -1); } return str; }; function endsInSeparator(str) { var last = str[str.length - 1]; return str.length > 1 && (last === '/' || (isWin && last === '\\')); } remove-trailing-separator-1.0.1/license000066400000000000000000000012701277172054100201660ustar00rootroot00000000000000Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.remove-trailing-separator-1.0.1/package.json000066400000000000000000000015171277172054100211130ustar00rootroot00000000000000{ "name": "remove-trailing-separator", "version": "1.0.1", "description": "Removes separators from the end of the string.", "main": "index.js", "files": [ "index.js" ], "scripts": { "lint": "xo", "pretest": "npm run lint", "test": "nyc ava", "report": "nyc report --reporter=html" }, "repository": { "type": "git", "url": "git+https://github.com/darsain/remove-trailing-separator.git" }, "keywords": [ "remove", "strip", "trailing", "separator" ], "author": "darsain", "license": "ISC", "bugs": { "url": "https://github.com/darsain/remove-trailing-separator/issues" }, "homepage": "https://github.com/darsain/remove-trailing-separator#readme", "devDependencies": { "ava": "^0.16.0", "coveralls": "^2.11.14", "nyc": "^8.3.0", "xo": "^0.16.0" } } remove-trailing-separator-1.0.1/readme.md000066400000000000000000000033751277172054100204100ustar00rootroot00000000000000# 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('') // '' ``` ## 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-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=masterremove-trailing-separator-1.0.1/test/000077500000000000000000000000001277172054100176005ustar00rootroot00000000000000remove-trailing-separator-1.0.1/test/index.js000066400000000000000000000023751277172054100212540ustar00rootroot00000000000000import test from 'ava'; import removeTrailingSeparator from '..'; const isWin = process.platform === 'win32'; test('strip trailing separator:', t => { t.is(removeTrailingSeparator('foo/'), 'foo'); let platformExpected = isWin ? 'foo' : 'foo\\'; t.is(removeTrailingSeparator('foo\\'), platformExpected); }); test('don\'t strip when it\'s the only char in the string', t => { t.is(removeTrailingSeparator('/'), '/'); t.is(removeTrailingSeparator('\\'), '\\'); }); test('strip only trailing separator:', t => { t.is(removeTrailingSeparator('/test/foo/bar/'), '/test/foo/bar'); let platformExpected = isWin ? '\\test\\foo\\bar' : '\\test\\foo\\bar\\'; t.is(removeTrailingSeparator('\\test\\foo\\bar\\'), platformExpected); }); test('strip multiple trailing separators', t => { t.is(removeTrailingSeparator('/test//'), '/test'); let platformExpected = isWin ? '\\test' : '\\test\\\\'; t.is(removeTrailingSeparator('\\test\\\\'), platformExpected); }); test('leave 1st separator in a string of only separators', t => { t.is(removeTrailingSeparator('////'), '/'); let platformExpected = isWin ? '\\' : '\\\\\\\\'; t.is(removeTrailingSeparator('\\\\\\\\'), platformExpected); }); test('return back empty string', t => { t.is(removeTrailingSeparator(''), ''); });