Salome HOME
Merge branch 'occ/new_mg_licnese' of https://codev-tuleap.cea.fr/plugins/git/salome...
[modules/smesh.git] / src / SMESHUtils / SMESH_MGLicenseKeyGen.cxx
index fa5b78858ad6766ce2b9beb1fdc357fcd4735865..ec06d988548ae0d1a1a1010a6e161dda1fc55e62 100644 (file)
@@ -201,17 +201,32 @@ namespace
 
   bool isURL( LibraryFile & libraryFile )
   {
-    enum { SCHEME = 2, AUTHORITY = 4, PATH = 5 }; // sub-strings
-    std::regex urlRegex ( R"(^(([^:\/?#]+):)?(//([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)",
-                          std::regex::extended );
-    std::smatch matchResult;
-
-    libraryFile._isURL = false;
-    if ( std::regex_match( libraryFile._name, matchResult, urlRegex ))
-      libraryFile._isURL = ( !matchResult.str( SCHEME    ).empty() &&
-                             !matchResult.str( AUTHORITY ).empty() &&
-                             !matchResult.str( PATH      ).empty() );
-
+    {// round1
+      enum { SCHEME = 2, AUTHORITY = 4, PATH = 5 }; // sub-strings
+      std::regex urlRegex ( R"(^(([^:\/?#]+):)?(//([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)",
+                            std::regex::extended );
+      std::smatch matchResult;
+
+      libraryFile._isURL = false;
+      if ( std::regex_match( libraryFile._name, matchResult, urlRegex ))
+        libraryFile._isURL = ( !matchResult.str( SCHEME    ).empty() &&
+                              !matchResult.str( AUTHORITY ).empty() &&
+                              !matchResult.str( PATH      ).empty() );
+    }
+    if(libraryFile._isURL)
+      return true;
+    {// round2
+      enum { HOST = 2, PORT = 3, PATH = 4 }; // sub-strings
+      std::regex urlRegex ( R"(^(([^:\/?#]+):)?([^/]+)?(/[^#]*))",
+                            std::regex::extended );
+      std::smatch matchResult;
+
+      libraryFile._isURL = false;
+      if ( std::regex_match( libraryFile._name, matchResult, urlRegex ))
+        libraryFile._isURL = ( !matchResult.str( HOST ).empty() &&
+                              !matchResult.str( PORT ).empty() &&
+                              !matchResult.str( PATH ).empty() );
+    }
     return libraryFile._isURL;
   }