Jump to content
This site is currently in alpha, so you will run into rough edges.

Module:Tracked in: Difference between revisions

From The Deep Tech Wiki
w>Novem Linguae
detect issue numbers not at the end of a URL
 
m 1 revision imported
 
(No difference)

Latest revision as of 03:34, 15 November 2025

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

-- Utility functions for {{Tracked in}}, which is a template similar to {{Tracked}}, but lets you link to issues and pull requests that aren't on Phabricator, e.g. GitHub, GitLab, etc.

local p = {}

-- {{#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 "Issue #" .. issueNumber -- add a # sign in front of the number. can't use #, that creates a numbered list
    end
end

return p