diff --git a/src/string/String.cpp b/src/string/String.cpp index 87564c8..17d9b33 100644 --- a/src/string/String.cpp +++ b/src/string/String.cpp @@ -51,7 +51,7 @@ bool Hyprutils::String::isNumber(const std::string& str, bool allowfloat) { } } - if (str.back() == '.') + if (!isdigit(str.back())) return false; return true; diff --git a/tests/string.cpp b/tests/string.cpp index 813cfe6..67060ed 100644 --- a/tests/string.cpp +++ b/tests/string.cpp @@ -19,6 +19,7 @@ int main(int argc, char** argv, char** envp) { EXPECT(isNumber("---3423--432s"), false); EXPECT(isNumber("1s"), false); EXPECT(isNumber(""), false); + EXPECT(isNumber("-"), false); EXPECT(isNumber("--0"), false); EXPECT(isNumber("abc"), false); EXPECT(isNumber("0.0", true), true);