]> git.ipfire.org Git - pbs.git/commitdiff
backend: Add function that makes URL absolute
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 15 May 2023 10:26:29 +0000 (10:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 15 May 2023 10:26:29 +0000 (10:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/__init__.py

index 98c06621331e6c7ac725ac6ead82f775cb9071f4..3aa06f275f0c06f96e7e6f7d62f25aa665abe65c 100644 (file)
@@ -131,20 +131,26 @@ class Backend(object):
                """
                return os.path.join(self.basepath, *args)
 
-       def path_to_url(self, path):
+       def url_to(self, url):
                """
-                       Takes a path to a file on the file system and converts it into a URL
+                       Takes a relative URL and makes it absolute
                """
                # The base URL
                baseurl = self.settings.get("baseurl")
 
+               # Join it all together
+               return urllib.parse.urljoin(baseurl, url)
+
+       def path_to_url(self, path):
+               """
+                       Takes a path to a file on the file system and converts it into a URL
+               """
                # Path to package
                path = os.path.join(
                        "files", os.path.relpath(path, self.basepath),
                )
 
-               # Join it all together
-               return urllib.parse.urljoin(baseurl, path)
+               return self.url_to(path)
 
        def pakfire(self, *args, **kwargs):
                """