From 83203cd2e677706e0111892a7843b83263cb8bd9 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 26 Feb 2016 17:49:33 +0000 Subject: fetch2/__init__: Fix decodeurl to better handle urls without paths If we specify urls such as npm://somehost;someparams the fetcher currently does a poor job of handling mirrors of these urls due to deficiencies in the way decodeurl works. This is because "somehost" is returned as a path, not a host. This tweaks the code so that unless its a file url, the host is returned correctly. This patch also adds test cases for these urls to the exist set of test urls. We need to tweak the URI() class since this thinks this is a relative url which is clearly isn't. We also need to handle the fact that encodeurl will error if passed a url of this form (it would want the path to be '/'. Signed-off-by: Richard Purdie --- lib/bb/fetch2/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/bb/fetch2/__init__.py') diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py index 914553aaf7..5f0e6c9266 100644 --- a/lib/bb/fetch2/__init__.py +++ b/lib/bb/fetch2/__init__.py @@ -327,7 +327,7 @@ class URI(object): def path(self, path): self._path = path - if re.compile("^/").match(path): + if not path or re.compile("^/").match(path): self.relative = False else: self.relative = True @@ -375,9 +375,12 @@ def decodeurl(url): if locidx != -1 and type.lower() != 'file': host = location[:locidx] path = location[locidx:] - else: + elif type.lower() == 'file': host = "" path = location + else: + host = location + path = "" if user: m = re.compile('(?P[^:]+)(:?(?P.*))').match(user) if m: -- cgit 1.2.3-korg