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

    remove-trailing-separator

Removes separators from the end of the string.


Version published
Weekly downloads
13M
increased by2.92%
Maintainers
1
Install size
4.99 kB
Created
Weekly downloads
 

Readme

Source

remove-trailing-separator

NPM version Build Status: Linux Build Status: Windows Coverage Status

Removes all separators from the end of a string.

Install

npm install remove-trailing-separator

Examples

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:

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

Keywords

FAQs

Last updated on 16 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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