Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
remove-trailing-separator
Advanced tools
The remove-trailing-separator npm package is a simple utility that helps in removing trailing separators from a given path string. This can be particularly useful in file path manipulations where consistency in path formatting is required.
Remove trailing path separator
This feature allows the removal of trailing slashes (or other relevant separators) from a file path. It ensures that the path is normalized without an ending separator, which is useful for concatenating paths or when directories are compared.
const removeTrailingSeparator = require('remove-trailing-separator');
console.log(removeTrailingSeparator('example/path/')); // Outputs: 'example/path'
normalize-path is similar to remove-trailing-separator but offers broader functionality including the normalization of path strings by removing unnecessary slashes and resolving '.' and '..' segments. Unlike remove-trailing-separator, which only removes the trailing separator, normalize-path adjusts the entire path structure.
The slash package converts Windows backslash paths to slash paths, which is somewhat related but not identical to remove-trailing-separator. While slash changes the type of separators, remove-trailing-separator specifically focuses on removing unnecessary trailing separators.
Removes all separators from the end of a string.
npm install remove-trailing-separator
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('') // ''
\
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'
FAQs
Removes separators from the end of the string.
The npm package remove-trailing-separator receives a total of 11,535,346 weekly downloads. As such, remove-trailing-separator popularity was classified as popular.
We found that remove-trailing-separator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.