Module:URLEncode: Difference between revisions

From The Joe Frank Wiki
s/r in function
a
 
Line 2: Line 2:


function p.encode(frame)
function p.encode(frame)
    local str = frame.args[1] or ''
     -- Retrieve the current page title directly
     -- Decode any HTML entities back to their original characters
     local title = mw.title.getCurrentTitle().text
     str = mw.text.decode(str)
     -- Perform URL encoding
     -- Perform URL encoding
     return mw.uri.encode(str, 'PATH')
     return mw.uri.encode(title, 'PATH')
end
end


return p
return p

Latest revision as of 07:08, 27 October 2024

Documentation for this module may be created at Module:URLEncode/doc

local p = {}

function p.encode(frame)
    -- Retrieve the current page title directly
    local title = mw.title.getCurrentTitle().text
    -- Perform URL encoding
    return mw.uri.encode(title, 'PATH')
end

return p