File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -57,10 +57,13 @@ local furi = require 'file-uri'
5757local export = {}
5858
5959function export .getLocalPath (uri )
60- local relativePath = fs .relative (furi .decode (uri ), DOC ):string ()
61- if relativePath :sub (1 , 2 ) == ' ..' then
60+ local file_canonical = fs .canonical (furi .decode (uri )):string ()
61+ local doc_canonical = fs .canonical (DOC ):string ()
62+ local relativePath = fs .relative (file_canonical , doc_canonical ):string ()
63+ local _ , j = file_canonical :find (doc_canonical , 1 , true )
64+ if not j then
6265 -- not under project directory
63- return ' [FOREIGN] ' .. uri
66+ return ' [FOREIGN] ' .. file_canonical
6467 end
6568 return relativePath
6669end
Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ function doc.runCLI()
185185 return
186186 end
187187
188- local rootUri = furi .encode (fs .absolute (fs .path (DOC )):string ())
188+ local rootUri = furi .encode (fs .canonical (fs .path (DOC )):string ())
189189 if not rootUri then
190190 print (lang .script (' CLI_CHECK_ERROR_URI' , DOC ))
191191 return
You can’t perform that action at this time.
0 commit comments