File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from pathlib import Path
2+ from pygls .uris import from_fs_path , to_fs_path
3+ import typing as t
24
35
46class URI :
@@ -25,12 +27,11 @@ def __repr__(self) -> str:
2527 return f"URI({ self .value } )"
2628
2729 def to_path (self ) -> Path :
28- # Remove file:// prefix and handle Windows paths
29- path_str = self .value .removeprefix ("file://" )
30- # Handle both forward and backward slashes
31- return Path (path_str )
30+ p = to_fs_path (self .value )
31+ return Path (p )
3232
3333 @staticmethod
34- def from_path (path : Path ) -> "URI" :
35- # Always use forward slashes in URIs
36- return URI (f"file://{ path .absolute ().as_posix ()} " )
34+ def from_path (path : t .Union [str , Path ]) -> "URI" :
35+ if isinstance (path , Path ):
36+ path = path .as_posix ()
37+ return URI (from_fs_path (path ))
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments