
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.
svg-path-parse
Advanced tools
This is a small library to normalise SVG paths based on those normalised paths.
This is a small library to normalise SVG paths based on those normalised paths.
Note: this package works with path data strings and Paths, not with full svg xml sources.
npm install svg-path-parse
Takes an SVG path string. The following code…
const { pathParse, serializePath } = require('svg-path-parse')
const pathDatas = pathParse(__your_path__).getSegments()
// const pathDatas = pathParse(__your_path__).normalize({round: 2, transform: 'translate(10, 10) scale(0.5)'})
// const pathDatas = pathParse(__your_path__).relNormalize({round: 2,transform: 'translate(10, 10) scale(0.5)'})
// const pathDatas = pathParse(__your_path__).absNormalize({round: 2,transform: 'translate(10, 10) scale(0.5)'})
// const pathDatas = pathParse(__your_path__).absCairo({round: 2,transform: 'translate(10, 10) scale(0.5)'})
// const pathDatas = pathParse(__your_path__).relCairo({round: 2,transform: 'translate(10, 10) scale(0.5)'})
// out put
// { err: '', segments:[ { 'type': 'M', 'args' : [230, 230] }] }
serializePath(pathDatas)
console.log('pathDatas', serializePath(pathDatas))
// out put
// M896 480C894.656 480 893.536 480.608 892.256 480.768C894.72 479.84 893.568 479.232 892.256 479.232z
Convert all path commands,data format as follows:
// example
{
err: '',
segments:[
[ 'M', 230, 230 ],
[ 'A', 45, 45, 0, 1, 1, 275, 275 ],
[ 'L', 275, 230 ],
[ 'Z' ]
]
}
Convert all path commands,data format as follows:
// example
{
err: '',
segments:[
{ 'type': 'M', 'args' : [230, 230] },
{ 'type': 'A', 'args' : [45, 45, 0, 1, 1, 275, 275] },
{ 'type': 'l', 'args' : [0, -45] },
{ 'type': 'z', 'args' : [] }
]
}
Converts all path commands to absolute, data format as follows:
// example
{
err: '',
segments:[
{ 'type': 'M', 'args' : [230, 230] },
{ 'type': 'A', 'args' : [45, 45, 0, 1, 1, 275, 275] },
{ 'type': 'L', 'args' : [275, 230] },
{ 'type': 'Z', 'args' : [] }
]
}
Converts all path commands to relative. Useful to reduce output size, data format as follows:
// example
{
err: '',
segments:[
{ type: 'M', args: [ 230, 230 ] },
{ type: 'a', args: [ 45, 45, 0, 1, 1, 45, 45 ] },
{ type: 'l', args: [ 0, -45 ] },
{ type: 'z', args: [] }
]
}
Converts all path commands to absolute based on cairo and CairoSVG. Converts smooth curves Q/q/T/t/S/s with "missed" control point to generic curves (C), Converts V/v/H/h to lineto (L), data format as follows:
// example
{
err: '',
segments:[
{ type: 'M', args: [ 230, 230 ] },
{ type: 'A',
args: [ 230, 230, 0, 1, 1, 45, 0, 45, 3.14, 1.57 ] },
{ type: 'L', args: [ 275, 230 ] },
{ type: 'Z', args: [] }
]
}
Converts all path commands to relative on cairo and CairoSVG. Converts smooth curves Q/q/T/t/S/s with "missed" control point to generic curves (c), Converts V/v/H/h to lineto (l), data format as follows:
// example
{
err: '',
segments:[
{ type: 'M', args: [ 230, 230 ] },
{ type: 'a',
args: [ 230, 230, 0, 1, 1, 45, 0, 45, 3.14, 1.57 ] },
{ type: 'l', args: [ 0, -45 ] },
{ type: 'z', args: [] }
]
}
Returns final path string.
FAQs
This is a small library to normalise SVG paths based on those normalised paths.
We found that svg-path-parse 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.