summaryrefslogtreecommitdiff
path: root/script/uri.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-05-13 17:09:50 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-05-13 17:10:26 +0800
commit1d0a33637635a4f5a9a614c4bb0de17202c2d375 (patch)
tree828b2932ffc68f06c1f73921e9c62a3220e93b03 /script/uri.lua
parentd7daade3a3b8f4a5e33bca3df7ec0656d93684c2 (diff)
downloadlua-language-server-1d0a33637635a4f5a9a614c4bb0de17202c2d375.zip
改成使用自己的 file-uri
Diffstat (limited to 'script/uri.lua')
-rw-r--r--script/uri.lua24
1 files changed, 5 insertions, 19 deletions
diff --git a/script/uri.lua b/script/uri.lua
index e00b7138..8f570daf 100644
--- a/script/uri.lua
+++ b/script/uri.lua
@@ -1,26 +1,12 @@
local fs = require 'bee.filesystem'
-local platform = require 'bee.platform'
-local sandbox = require 'sandbox'
-local luaUriPath = (ROOT / 'script' / '3rd' / 'lua-uri'):string()
-local URI = sandbox('uri.lua', luaUriPath, io.open)
-local URI_FILE = sandbox('uri/file.lua', luaUriPath, io.open)
-local OS = platform.OS == 'Windows' and 'win32' or 'unix'
+local furi = require 'file-uri'
-local function decode(uri)
- local obj = URI:new(uri)
- if not obj.filesystem_path then
- return nil
- end
- local fullPath = obj:filesystem_path(OS)
- local path = fs.path(fullPath)
- return path
+local function encode(path)
+ return furi.encode(path:string())
end
-local function encode(path)
- local fullPath = fs.absolute(ROOT / path)
- local obj = URI_FILE.make_file_uri(fullPath:string(), OS)
- local uri = obj:uri()
- return uri
+local function decode(uri)
+ return fs.path(furi.decode(uri))
end
return {