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.
@penname/routepath
Advanced tools
npm install --save @penname/routepath
Convenient API route interface.
const RoutePath = require('@penname/routepath')
const route = RoutePath.instance({ path: '/article/:id', baseUrl: 'example.com' })
const url = route.buildUrl({
params: { id: 'abc123' },
query: { position: 'middle', ref: 'twitter' },
})
console.log(url)
// prints: example.com/article/abc123?position=middle&ref=twitter
const path = route.buildPath({
params: { id: 'abc123' },
query: { position: 'middle', ref: 'twitter' },
})
console.log(path)
// prints: /article/abc123?position=middle&ref=twitter
#instance()
Create a route path instance with a minimum of baseUrl
, path
:
const route = RoutePath.instance({ path: '/article/:id', baseUrl: 'https://example.com' })
#buildUrl()
Builds the url from the route path with the provided params
and query
const route = RoutePath.instance({ path: '/article/:id', baseUrl: 'localhost:3000/api/' })
const url = route.buildUrl({
params: { id: 'abc123' },
query: { position: 'middle', ref: 'twitter' },
})
console.log(url)
// prints: localhost:3000/api/article/abc123?position=middle&ref=twitter
#buildPath()
Builds the url path, no host, from the route path with the provided params
and query
const route = RoutePath.instance({
path: '/user/:userId/article/:articleId',
baseUrl: 'http://www.example.com',
})
const path = route.buildPath({
params: { userId: 'u1cba', articleId: 'abc123' },
query: { position: 'middle', date: 1609036608349 },
})
console.log(path)
// prints: /user/u1cba/article/abc123?position=middle&date=1609036608349
#fromSerialized()
const routeFromJsonString = RoutePath.fromSerialized(
`{path: "/user/:id/articles", "baseUrl": 'example.com/api/' }`,
)
const url = route.buildUrl({
params: { id: 'u1cba' },
query: { from: 'abc456', limit: 15 },
})
console.log(url)
// prints: example.com/api/user/u1cba/articles?from=abc456&limit=15
FAQs
Convenient API route interface.
We found that @penname/routepath demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.