diff --git a/plugin/core/url.py b/plugin/core/url.py index c167cd344..ba1c8287c 100644 --- a/plugin/core/url.py +++ b/plugin/core/url.py @@ -50,11 +50,12 @@ def parse_uri(uri: str) -> Tuple[str, str]: if parsed.scheme == "file": path = url2pathname(parsed.path) if os.name == 'nt': + netloc = url2pathname(parsed.netloc) path = path.lstrip("\\") path = re.sub(r"^([a-z]):", _uppercase_driveletter, path) - if parsed.netloc: + if netloc: # Convert to UNC path - return parsed.scheme, "\\\\{}\\{}".format(parsed.netloc, path) + return parsed.scheme, "\\\\{}\\{}".format(netloc, path) else: return parsed.scheme, path return parsed.scheme, path diff --git a/tests/test_url.py b/tests/test_url.py index 1409f4892..d1fe885ff 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -35,6 +35,11 @@ def test_unc_path(self): self.assertEqual(scheme, "file") self.assertEqual(path, R'\\192.168.80.2\D$\www\File.php') + def test_wsl_path(self): + scheme, path = parse_uri('file://wsl%24/Ubuntu-20.04/File.php') + self.assertEqual(scheme, "file") + self.assertEqual(path, R'\\wsl$\Ubuntu-20.04\File.php') + @unittest.skipIf(sys.platform.startswith("win"), "requires non-Windows") class NixTests(unittest.TestCase):