Jump to content

Module:Filter

From Wikisource

Filter = {};

--[[
CleanParentDirectories
 
Main entry point for Lua test function to strip redundant ../'s from page name.
 
Usage:
 
  {{#invoke:Filter|CleanParentDirectories|PageName}}
]]
 
function Filter.CleanParentDirectories(frame)
    local PageName = frame.args[1] or ""
    local oldPageName = ''
    while ( oldPageName ~= PageName ) do
        oldPageName = PageName
        PageName = mw.ustring.gsub( PageName, '/[^/]*/\.\./', '/' )..''
    end
    return PageName
end
 
return Filter