Fix nextfile expecting full path from prevfile
This commit is contained in:
parent
7a6d182454
commit
160b7509a2
|
@ -3,8 +3,8 @@ local prevfile = require "prevfile"
|
|||
local nextfile = {}
|
||||
|
||||
function nextfile.splitfilename(path)
|
||||
dir, name, ext = path:match("^(.*/)(.*)(%.%w*)")
|
||||
return dir, name, ext
|
||||
name, ext = path:match("^(.*)(%.%w*)")
|
||||
return name, ext
|
||||
end
|
||||
|
||||
function nextfile.nextletter(letter)
|
||||
|
@ -19,9 +19,9 @@ function nextfile.nextfile(directory, extension)
|
|||
local previous = prevfile.prevfile(directory)
|
||||
if previous == nil then return nil end
|
||||
|
||||
local dir, name, ext = nextfile.splitfilename(previous)
|
||||
local name, ext = nextfile.splitfilename(previous)
|
||||
|
||||
value = dir
|
||||
value = ""
|
||||
if tonumber(name) == nil then
|
||||
local lastletter = name:sub(#name)
|
||||
local nextletter = nextfile.nextletter(lastletter)
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
describe("splitfilename", function()
|
||||
local nextfile = require "nextfile"
|
||||
|
||||
it("should return the filename and extension of an absolute filepath", function()
|
||||
local dir, name, ext = nextfile.splitfilename("/testdir/701.txt")
|
||||
it("should return the filename and extension of a filename", function()
|
||||
local name, ext = nextfile.splitfilename("701.txt")
|
||||
|
||||
assert.are.equal("/testdir/", dir)
|
||||
assert.are.equal("701", name)
|
||||
assert.are.equal(".txt", ext)
|
||||
end)
|
||||
|
||||
it("should return the filename and extension of a relative filepath", function()
|
||||
local dir, name, ext = nextfile.splitfilename("../../foo/testdir/file.mp3")
|
||||
|
||||
assert.are.equal("../../foo/testdir/", dir)
|
||||
assert.are.equal("file", name)
|
||||
assert.are.equal(".mp3", ext)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("nextletter", function()
|
||||
|
|
Loading…
Reference in New Issue