
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
sweet-path
Advanced tools
Sweet Path is small utility class, for replacing path parameters. It's size around 1kb before gzip.
Sweet Path is small utility class, for replacing parameters in your text by specified pattern. Package is easy to use, Typescript oriented, and it's size around 1kb before gzip.
By default, Sweet Path is using :parameter pattern, and it will replace it with your value. You can see all available patterns in options section here.
const instance = new SweetPath("https://test.com/:entiityId");
// To replace parameter with your value
instance.insert({ entityId: 10 }); // "https://test.com/10"
// To get original string you passeed into SweetPath constructor;
instance.original; // "https://test.com/:entiityId"
If you don't have path parameters:
const instance = new SweetPath("https://test.com");
instance.insert(); // "https://test.com"
instance.original; // "https://test.com"
# instance.insert([,params])
# instance.original
SweetPath will care you passed all required params, but you have to specify it first in SweetPath Generic as Literal Type.
const instance = new SweetPath<"bookId" | "authorId">("https://test.com/books/:bookId/authors/:authorId");
instance.insert({ bookId: 10, authorId: 20 }); // https://test.com/books/10/authors/20
// In case you will not pass params specifed in Generic you'll get Typescript Error
instance.insert();
// Also will be Typescript Error
instance.insert({});
// Also will be Typescript Error
instance.insert({ bookId: 10 })
While creating SweetPath instance you are able to set additional options, which are not required!;
{
path: string;
}
path - set replace identifier. By default, SweetPath is using :param identifier.
:param{{param}}{param}[param]For example:
const instance = new SweetPath("https://test.com/{{entiityId}}", { path: "{{param}}" });
instance.insert({ entityId: 10 }); // "https://test.com/10"
instance.original; // "https://test.com/{{entiityId}}"
FAQs
Sweet Path is small utility class, for replacing path parameters. It's size around 1kb before gzip.
The npm package sweet-path receives a total of 217 weekly downloads. As such, sweet-path popularity was classified as not popular.
We found that sweet-path 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.