diff --git a/src/lib/svg-object-fns/create-svg-objects-from-pcb-fabrication-note-path.ts b/src/lib/svg-object-fns/create-svg-objects-from-pcb-fabrication-note-path.ts
index bfc20d2..53031cc 100644
--- a/src/lib/svg-object-fns/create-svg-objects-from-pcb-fabrication-note-path.ts
+++ b/src/lib/svg-object-fns/create-svg-objects-from-pcb-fabrication-note-path.ts
@@ -8,19 +8,21 @@ export function createSvgObjectsFromPcbFabricationNotePath(
): SvgObject[] {
if (!fabNotePath.route || !Array.isArray(fabNotePath.route)) return []
- let path = fabNotePath.route
- .map((point: any, index: number) => {
- const [x, y] = applyToPoint(transform, [point.x, point.y])
- return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`
- })
- .join(" ")
-
- // Close the path if it's not already closed
+ // Close the path if the first and last points are the same
const firstPoint = fabNotePath.route[0]
const lastPoint = fabNotePath.route[fabNotePath.route.length - 1]
- if (firstPoint!.x !== lastPoint!.x || firstPoint!.y !== lastPoint!.y) {
- path += " Z"
- }
+ const isClosed =
+ firstPoint!.x === lastPoint!.x && firstPoint!.y === lastPoint!.y
+
+ const path =
+ fabNotePath.route
+ .slice(0, isClosed ? -1 : undefined)
+ .map((point: any, index: number) => {
+ const [x, y] = applyToPoint(transform, [point.x, point.y])
+ return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`
+ })
+ .join(" ") + (isClosed ? " Z" : "")
+
return [
{
name: "path",
diff --git a/tests/__snapshots__/fabnotes.snap.svg b/tests/__snapshots__/fabnotes.snap.svg
index da57cd0..4f173e3 100644
--- a/tests/__snapshots__/fabnotes.snap.svg
+++ b/tests/__snapshots__/fabnotes.snap.svg
@@ -9,4 +9,4 @@
.pcb-silkscreen-top { stroke: #f2eda1; }
.pcb-silkscreen-bottom { stroke: #f2eda1; }
.pcb-silkscreen-text { fill: #f2eda1; }
- hello world!
\ No newline at end of file
+ hello world!
\ No newline at end of file