Jump to content

Module:Tracked in

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Novem Linguae (talk | contribs) at 13:16, 26 November 2021 (debug). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- Draft. Will be used in {{Tracked in}} once this is finished.

local p = {} --p stands for package

-- {{#invoke:Tracked in|getDomain|{{{1|}}}}}
function p.getDomain(frame)
    local url = frame.args[1]
    local domain = string.gsub(url, "www%.", "")
    domain = string.match(domain, 'https?:%/%/(.-)%/.*$')
    return domain
end

-- {{#invoke:Tracked in|getIssueNumber|{{{1|}}}}}
function p.getIssueNumber(frame)
    local url = frame.args[1]
    local issueNumber = string.match(url, '%d+$')
    if tonumber(issueNumber) == nil then
        return "ERROR: Issue number not found"
    else
        return "#" .. issueNumber -- add a # sign in front of the number. can't use #, that creates a numbered list
    end
end

return p