mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	fix(vim.fs.abspath): correctly handle UNC paths
This commit is contained in:
		@@ -725,7 +725,7 @@ function M.abspath(path)
 | 
			
		||||
    prefix, path = split_windows_path(path)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  if vim.startswith(path, '/') then
 | 
			
		||||
  if prefix == '//' or vim.startswith(path, '/') then
 | 
			
		||||
    -- Path is already absolute, do nothing
 | 
			
		||||
    return prefix .. path
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -361,8 +361,8 @@ describe('vim.fs', function()
 | 
			
		||||
    end)
 | 
			
		||||
 | 
			
		||||
    -- Opts required for testing posix paths and win paths
 | 
			
		||||
    local posix_opts = is_os('win') and { win = false } or {}
 | 
			
		||||
    local win_opts = is_os('win') and {} or { win = true }
 | 
			
		||||
    local posix_opts = { win = false }
 | 
			
		||||
    local win_opts = { win = true }
 | 
			
		||||
 | 
			
		||||
    it('preserves leading double slashes in POSIX paths', function()
 | 
			
		||||
      eq('//foo', vim.fs.normalize('//foo', posix_opts))
 | 
			
		||||
@@ -483,6 +483,7 @@ describe('vim.fs', function()
 | 
			
		||||
      if is_os('win') then
 | 
			
		||||
        eq([[C:/foo]], vim.fs.abspath([[C:\foo]]))
 | 
			
		||||
        eq([[C:/foo/../.]], vim.fs.abspath([[C:\foo\..\.]]))
 | 
			
		||||
        eq('//foo/bar', vim.fs.abspath('\\\\foo\\bar'))
 | 
			
		||||
      else
 | 
			
		||||
        eq('/foo/../.', vim.fs.abspath('/foo/../.'))
 | 
			
		||||
        eq('/foo/bar', vim.fs.abspath('/foo/bar'))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user