]> git.mxchange.org Git - fba.git/blobdiff - fba/http/federation.py
Continued:
[fba.git] / fba / http / federation.py
index 0523938e8fe8f30c96866f894fa7bc12d43ea633..136a4ea3158b848c2af41e20b64fa4ca09b597cd 100644 (file)
@@ -69,11 +69,13 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
         raise ValueError(f"Parameter command='{command}' but origin is None, please fix invoking this function.")
     elif not isinstance(path, str) and path is not None:
         raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
+    elif path is not None and not path.startswith("/"):
+        raise ValueError(f"path='{path}' does not start with a slash")
     elif _DEPTH > 0 and instances.is_recent(domain, "last_instance_fetch"):
         raise ValueError(f"domain='{domain}' has recently been fetched but function was invoked")
     elif software is None and not instances.is_recent(domain, "last_nodeinfo"):
         try:
-            logger.debug("Software for domain='%s' is not set, determining ...", domain)
+            logger.debug("Software for domain='%s',path='%s' is not set, determining ...", domain, path)
             software = determine_software(domain, path)
         except network.exceptions as exception:
             logger.warning("Exception '%s' during determining software type", type(exception))
@@ -275,7 +277,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str:
     elif path == "":
         raise ValueError("Parameter 'path' is empty")
     elif not path.startswith("/"):
-        raise ValueError("path='{path}' does not start with / but should")
+        raise ValueError(f"path='{path}' does not start with / but should")
 
     software = None
 
@@ -387,6 +389,8 @@ def determine_software(domain: str, path: str = None) -> str:
         raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str) and path is not None:
         raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
+    elif path is not None and not path.startswith("/"):
+        raise ValueError(f"path='{path}' does not start with a slash")
 
     logger.debug("Fetching nodeinfo from domain='%s',path='%s' ...", domain, path)
     data = nodeinfo.fetch(domain, path)