Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
a tiny zero dependency library to join strings with slashes in them that isn't too smart about it!
a tiny zero dependency library to join strings with slashes in them that isn't too smart about it!
yarn add safe-join # or npm i safe-join
import { safeJoin } from 'safe-join'
safeJoin('foo', 'bar') // 'foo/bar'
safeJoin('foo/', 'bar') // 'foo/bar'
safeJoin('foo/', '/bar') // 'foo/bar'
safeJoin('foo', '/bar') // 'foo/bar'
safeJoin('http://foo/', '/bar') // 'http://foo/bar'
// works on multiple args too
safeJoin('foo', '/bar/', '/baz') // 'foo/bar/baz'
// etc
You might normally use path.join for this in Node but this works in the browser, also it doesnt swallow /
's when you need //
.
Uses typescript because why not.
It does NOT handle query strings for you e.g. safeJoin("https://foo", "bar", "&search=baz")
so be sure to handle those on your own. or use https://github.com/jfromaniello/url-join
so you know exactly what this
export function safeJoin(...args: string[]) {
return args.reduce(_safeJoin)
}
// thanks to https://twitter.com/swyx/status/1106839872096985088
function _safeJoin(a: string, b: string) {
return a.replace(/\/$/, '') + '/' + b.replace(/^\//, '')
}
https://github.com/jfromaniello/url-join
This project was bootstrapped with TSDX.
FAQs
a tiny zero dependency library to join strings with slashes in them that isn't too smart about it!
The npm package safe-join receives a total of 2,603 weekly downloads. As such, safe-join popularity was classified as popular.
We found that safe-join 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 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.