From f120b1c027df34eafbec7164df6adf9a060f9405 Mon Sep 17 00:00:00 2001 From: Raoul Wols Date: Mon, 21 Jun 2021 23:29:53 +0200 Subject: [PATCH] revert last commit --- plugin/core/url.py | 10 +++++----- tests/test_url.py | 5 ----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/plugin/core/url.py b/plugin/core/url.py index 6dd6e6b5b..993ee24a6 100644 --- a/plugin/core/url.py +++ b/plugin/core/url.py @@ -15,14 +15,14 @@ def filename_to_uri(file_name: str) -> str: Convert a file name obtained from view.file_name() into an URI """ prefix = sublime.installed_packages_path() - if file_name.startswith(prefix) and not os.path.exists(file_name): + if file_name.startswith(prefix): return _to_resource_uri(file_name, prefix) prefix = sublime.packages_path() if file_name.startswith(prefix) and not os.path.exists(file_name): return _to_resource_uri(file_name, prefix) - file_name = os.path.realpath(file_name) - file_name = re.sub(r'^([A-Z]):\\', _lowercase_driveletter, file_name) - return urljoin("file:", pathname2url(file_name)) + path = pathname2url(file_name) + re.sub(r"^([A-Z]):/", _lowercase_driveletter, path) + return urljoin("file:", path) def view_to_uri(view: sublime.View, foreign_uri: Optional[str] = None) -> str: @@ -62,4 +62,4 @@ def _lowercase_driveletter(match: Any) -> str: """ For compatibility with certain other language clients. """ - return "{}:\\".format(match.group(1).lower()) + return "{}:/".format(match.group(1).lower()) diff --git a/tests/test_url.py b/tests/test_url.py index 7aa39067e..186471ef7 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -18,11 +18,6 @@ def test_converts_encoded_bad_drive_uri_to_path(self): # url2pathname does not understand %3A self.assertEqual("c:\\dir ectory\\file.txt", uri_to_filename("file:///c%3A/dir%20ectory/file.txt")) - @unittest.skipUnless(sys.platform.startswith("win"), "requires Windows") - def test_converts_encoded_bad_drive_uri_to_path(self): - # url2pathname does not understand %3A - self.assertEqual("file:///c%3A/asdf/foo.txt", filename_to_uri("C:\\asdf\\foo.txt")) - class NixTests(unittest.TestCase):