Module:Urltowiki/sandbox: Difference between revisions

Content deleted Content added
modify wrappers
use ~= instead of not ==
 
(6 intermediate revisions by 2 users not shown)
Line 84:
function p._urlToWiki(args)
-- Check the input is valid.
 
if args.blank == "yes" then
local input = args[1] or args.url or ""
else
local input = args[1] or args.url or error("No URL specified", 2)
end
if type(input) ~= "string" then
if args.blankerror =~= "yesno" then
error("The URL must be a string value", 2)
if type(input) == "nil" then
local input = args[1] or args.url or error("No URL specified", 2)
else
error("The URL must be a string value", 2)
end
else
return ""
end
end
input = mw.text.trim(input)
Line 148 ⟶ 153:
wikitext = interwiki .. ":" .. wikitext
end
if fragment and not (args.section =~= "no") then
wikitext = wikitext .. "#" .. fragment
end
Line 164 ⟶ 169:
if link then
display = args[2] or args.display -- The display text in piped links.
if (display and type(display) ~= "string") then
if type(display)args.error ~= "stringno" then
error("Non-string display value detected")
else
display = nil
end
end
if display then
display = mw.text.trim(display) -- Trim whitespace.
-- If the page name is the same as the display value, don't pipe
Line 220 ⟶ 229:
function p.urlToWiki(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = {{'Template:Urltowiki','Template:Urltowiki/sandbox'}}
})
return p._urlToWiki(args)