From dc94ab8df48681de197cbc3b4603c1904f31e928 Mon Sep 17 00:00:00 2001
From: Thomas Lambert <t.lambert@uliege.be>
Date: Fri, 25 Nov 2022 22:13:14 +0100
Subject: [PATCH] fix: add check if wrong filetype is detected

Signed-off-by: Thomas Lambert <t.lambert@uliege.be>
---
 +af_tools/+utils/appendextension.m | 7 ++++++-
 CHANGELOG.md                       | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/+af_tools/+utils/appendextension.m b/+af_tools/+utils/appendextension.m
index 12b5850..a334faa 100644
--- a/+af_tools/+utils/appendextension.m
+++ b/+af_tools/+utils/appendextension.m
@@ -9,8 +9,13 @@ function str = appendextension(str, ext)
 
     % ----------------------------------------------------------------------------------------------
 
-    if isempty(regexp(str, [ext, '$'], 'once'))
+    [~, ~, fileExt] = fileparts(str);
+    if isempty(fileExt)
         str = strcat(str, ext);
+    elseif ~isempty(fileExt) && ~strcmp(fileExt, ext)
+        error('MATLAB:appendextension:IncorrectExtension', ...
+              'Incorrect extension. File %s is expected to be a ''%s''. Found ''%s''.', ...
+              str, ext, fileExt);
     end
 
 end
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0601b31..fd975b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - **formatairfoilcoord**: fix issue with autosave
 - **xf2mat**: add error when input is not a proper xfoil/xflr5 result
 - **plotpolar**: fix issue when unavailable data
+- **all**: add check if wrong filetype is detected
 
 ## [4.0.0] - 2022-06-09
 
-- 
GitLab