Module:Tracked in: Difference between revisions
Appearance
Content deleted Content added
# -> Issue # |
handle URLs that end in / |
||
Line 14: | Line 14: | ||
function p.getIssueNumber(frame) |
function p.getIssueNumber(frame) |
||
local url = frame.args[1] |
local url = frame.args[1] |
||
local issueNumber = string.match(url, '%d+$') |
local issueNumber = string.match(url, '(%d+)/?$') |
||
if tonumber(issueNumber) == nil then |
if tonumber(issueNumber) == nil then |
||
return "ERROR: Issue number not found" |
return "ERROR: Issue number not found" |
Revision as of 13:27, 26 November 2021
Implements {{tracked in}}
-- 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 "Issue #" .. issueNumber -- add a # sign in front of the number. can't use #, that creates a numbered list
end
end
return p