diff --git a/plugins/applyTransforms.js b/plugins/applyTransforms.js
index 6b90acf50..091cd0fb1 100644
--- a/plugins/applyTransforms.js
+++ b/plugins/applyTransforms.js
@@ -212,7 +212,7 @@ const applyMatrixToPathData = (pathData, matrix) => {
}
// horizontal lineto (x)
- // convert to lineto to handle two-dimentional transforms
+ // convert to lineto to handle two-dimensional transforms
if (command === 'H') {
command = 'L';
args = [args[0], cursor[1]];
@@ -223,7 +223,7 @@ const applyMatrixToPathData = (pathData, matrix) => {
}
// vertical lineto (y)
- // convert to lineto to handle two-dimentional transforms
+ // convert to lineto to handle two-dimensional transforms
if (command === 'V') {
command = 'L';
args = [cursor[0], args[0]];
diff --git a/plugins/convertPathData.js b/plugins/convertPathData.js
index 9a8cbc813..649797230 100644
--- a/plugins/convertPathData.js
+++ b/plugins/convertPathData.js
@@ -172,10 +172,13 @@ export const fn = (root, params) => {
computedStyle['stroke-linejoin'].value === 'round'
: true;
- var data = path2js(node);
+ let data = path2js(node);
// TODO: get rid of functions returns
if (data.length) {
+ const includesVertices = data.some(
+ (item) => item.command !== 'm' && item.command !== 'M',
+ );
convertToRelative(data);
data = filters(data, newParams, {
@@ -188,6 +191,23 @@ export const fn = (root, params) => {
data = convertToMixed(data, newParams);
}
+ const hasMarker =
+ node.attributes['marker-start'] != null ||
+ node.attributes['marker-end'] != null;
+ const isMarkersOnlyPath =
+ hasMarker &&
+ includesVertices &&
+ data.every(
+ (item) => item.command === 'm' || item.command === 'M',
+ );
+
+ if (isMarkersOnlyPath) {
+ data.push({
+ command: 'z',
+ args: [],
+ });
+ }
+
// @ts-ignore
js2path(node, data, newParams);
}
diff --git a/test/plugins/convertPathData.37.svg.txt b/test/plugins/convertPathData.37.svg.txt
new file mode 100644
index 000000000..ff033e775
--- /dev/null
+++ b/test/plugins/convertPathData.37.svg.txt
@@ -0,0 +1,30 @@
+Must preserve vertex for markers only path for consistent rendering across clients.
+Must not add vertices if markers only path did not have commands other than M/m anyway.
+
+See: https://github.com/svg/svgo/issues/1493
+
+===
+
+
+
+@@@
+
+