Skip to content

Commit 5de0759

Browse files
Refactor URI validation logic in EtpHelpers
Moved complex data object URI validation from validateUri to a dedicated validateDataObjectUri function, simplifying validateUri and improving code clarity.
1 parent 4618322 commit 5de0759

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/etp/EtpHelpers.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,15 @@ std::string ETP_NS::EtpHelpers::getDataspaceUri(const std::string& uri)
5353
return uri.substr(0, closingParenthesisPos+1);
5454
}
5555

56-
bool ETP_NS::EtpHelpers::validateUri(const std::string & uri)
56+
bool ETP_NS::EtpHelpers::validateUri(const std::string& uri)
5757
{
5858
// Regular expressions are not handled before GCC 4.9
5959
// https://stackoverflow.com/questions/12530406/is-gcc-4-8-or-earlier-buggy-about-regular-expressions
60-
return
61-
std::regex_match(uri, std::regex("^eml:///(dataspace[(]'.*'[)])?", std::regex::ECMAScript)) ||
62-
std::regex_match(uri, std::regex("^eml:///(dataspace[(]'.*'[)]/)?(resqml20|eml20)\.obj_[a-zA-Z0-9]+[(][a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}(,.*)?[)]", std::regex::ECMAScript)) ||
63-
std::regex_match(uri, std::regex("^eml:///(dataspace[(]'.*'[)]/)?(witsml|resqml|prodml|eml)([0-9]{2})\.[a-zA-Z0-9]+[(][a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}(,.*)?[)]", std::regex::ECMAScript));
60+
return std::regex_match(uri, std::regex("^eml:///(dataspace[(]'.*'[)])?", std::regex::ECMAScript)) ||
61+
validateDataObjectUri(uri);
6462
}
6563

66-
bool ETP_NS::EtpHelpers::validateDataObjectUri(const std::string & uri)
64+
bool ETP_NS::EtpHelpers::validateDataObjectUri(const std::string& uri)
6765
{
6866
// Regular expressions are not handled before GCC 4.9
6967
// https://stackoverflow.com/questions/12530406/is-gcc-4-8-or-earlier-buggy-about-regular-expressions

0 commit comments

Comments
 (0)