Open main menu

Changes

Module:URL

136 bytes added, 18:55, 11 September 2022
per edit request on talk page - update
-- If it's an HTTP[S] URL without the double slash, fix it.
url = mw.ustring.gsub(url, '^[Hh][Tt][Tt][Pp]([Ss]?):(/?)([^/])', 'http%1://%3')
 
-- Handle URLs from Wikidata of the format http://
url = mw.ustring.gsub(url, '^[Hh][Tt][Tt][Pp]([Ss]?)://', 'http%1://')
local uri = safeUri(url)
local msg = templateArgs.msg or parentArgs.msg or 'no'
url = url or extractUrl(templateArgs) or extractUrl(parentArgs) or ''
-- if the url came from a Wikidata call, it might have a pen icon appended
-- we want to keep that and add it back at the end.
local u1, penicon = mw.ustring.match( url, "(.*)(&nbsp;<span class='penicon.*)" )
if penicon then url = u1 end
-- strip out html tags and [ ] from url
url = (url or ''):gsub("<[^>]*>", ""):gsub("[%[%]]", "")
-- truncate anything after a space
url = url:gsub("%%20", " "):gsub(" .*", "")
return (p._url(url, text, msg) or "") .. (penicon or "")
end
return p
Anonymous user