Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
trailing-slash-it
Advanced tools
trailing-slash-it
appends a forward slash to a string. It will remove trailing
forward slashes if they exist already, before adding a trailing forward
slash. This prevents double slashing a string or path.
$ npm install --save trailing-slash-it
var trailingSlashIt = require('trailing-slash-it');
trailingSlashIt('foo'); // 'foo/'
trailingSlashIt('foo/'); // 'foo/'
trailingSlashIt('foo//'); // 'foo/'
trailingSlashIt('foo///'); // 'foo/'
trailingSlashIt('foo\\'); // 'foo/'
trailingSlashIt('foo\\\\'); // 'foo/'
trailingSlashIt('foo\\/\\/'); // 'foo/'
If you need to make sure that something does NOT have a trailing slash, you can do that as well:
import {
trailingSlashIt,
unTrailingSlashIt,
} from 'trailing-slash-it';
trailingSlashIt('foo'); // 'foo/'
unTrailingSlashIt('foo'); // 'foo'
unTrailingSlashIt('foo/'); // 'foo'
unTrailingSlashIt('foo//'); // 'foo'
unTrailingSlashIt('foo///'); // 'foo'
unTrailingSlashIt('foo\\'); // 'foo'
unTrailingSlashIt('foo\\\\'); // 'foo'
unTrailingSlashIt('foo\\/\\/'); // 'foo'
Based on WordPress' PHP function trailingslashit().
0.3.0 - Strip backslashes as well as forward slashes.
GNU GPLv3
FAQs
Add or remove trailing slashes.
We found that trailing-slash-it 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.