Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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:
import join from 'safe-join'
join('foo', 'bar') // 'foo/bar'
join('foo/', 'bar') // 'foo/bar'
join('foo/', '/bar') // 'foo/bar'
join('foo', '/bar') // 'foo/bar'
join('http://foo/', '/bar') // 'http://foo/bar'
// works on multiple args too
join('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. join("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 default function safeJoin(...args: string[]) {
return args.reduce(_safeJoin)
}
function _safeJoin(a: string, b: string) {
let isTrailingSlash, isLeadingSlash
if (a.length > 1 && a.slice(-1)[0] === '/') isTrailingSlash = true
if (b.length > 1 && b[0] === '/') isLeadingSlash = true
if (isTrailingSlash && isLeadingSlash) return a + b.slice(1)
else if (!isTrailingSlash && !isLeadingSlash) return a + '/' + b
else return a + b
}
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!
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 uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.