From 0b519c2b7f9fb73d0de6d0b3fa1f1078d822a06a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 9 Jan 2023 23:05:36 +0100 Subject: [PATCH] Only do the german->english footprint conversion if the footprint contains german text Otherwise this had broken the viewing of passive components. --- src/Services/Attachments/AttachmentPathResolver.php | 5 +++++ tests/Services/Attachments/AttachmentPathResolverTest.php | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/Services/Attachments/AttachmentPathResolver.php b/src/Services/Attachments/AttachmentPathResolver.php index f960ecfa..508c5fb9 100644 --- a/src/Services/Attachments/AttachmentPathResolver.php +++ b/src/Services/Attachments/AttachmentPathResolver.php @@ -366,6 +366,11 @@ class AttachmentPathResolver public function convertOldFootprintPath(string $old_path): string { + //Only do the conversion if it contains a german string (meaning it has one of the four former base folders in its path) + if (!preg_match('/%FOOTPRINTS%\/(Passiv|Aktiv|Akustik|Elektromechanik|Optik)\//', $old_path)) { + return $old_path; + } + return strtr($old_path, self::OLD_FOOTPINT_PATH_REPLACEMENT); } } diff --git a/tests/Services/Attachments/AttachmentPathResolverTest.php b/tests/Services/Attachments/AttachmentPathResolverTest.php index 3292d7f8..9edde560 100644 --- a/tests/Services/Attachments/AttachmentPathResolverTest.php +++ b/tests/Services/Attachments/AttachmentPathResolverTest.php @@ -154,6 +154,9 @@ class AttachmentPathResolverTest extends WebTestCase yield [$this->footprint_path . '/Active/ICs/TO/IC_TO126.png', '%FOOTPRINTS%/Aktiv/ICs/TO/IC_TO126.png']; yield [$this->footprint_path . '/Electromechanics/Switches_Buttons/RotarySwitches/ROTARY_SWITCH_DIP10.png', '%FOOTPRINTS%/Elektromechanik/Schalter_Taster/Drehschalter/DREHSCHALTER_DIP10.png']; yield [$this->footprint_path . '/Electromechanics/Connectors/DINConnectors/SOCKET_DIN_MAB_4.png', '%FOOTPRINTS%/Elektromechanik/Verbinder/Rundsteckverbinder/BUCHSE_DIN_MAB_4.png']; + + //Leave english pathes untouched + yield [$this->footprint_path . '/Passive/Capacitors/CAPACITOR_CTS_A_15MM.png', '%FOOTPRINTS%/Passive/Capacitors/CAPACITOR_CTS_A_15MM.png']; } /**