From: Michael Tremer Date: Mon, 15 May 2023 10:26:29 +0000 (+0000) Subject: backend: Add function that makes URL absolute X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=262d04b5831ac5b99876a9413fccf792a6815432;p=pbs.git backend: Add function that makes URL absolute Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index 98c06621..3aa06f27 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -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): """