Módulu:URL

De Wikipedia

La documentación pa esti módulu pue crease en Módulu:URL/usu

local z = {}

function z.enlazar(url, texto)
    if not url then
		return
	elseif url:find('%[') then
		return url
	elseif z.esValida(url) then
		urlCorregida = url
	else
		urlCorregida = 'http://' .. url
	end
	
	if texto then
	    return '[' .. urlCorregida .. ' ' .. texto .. ']'
	else
		textoCorregido = urlCorregida:match('^http://(.+)') or 
		                 urlCorregida:match('^https://(.+)') or
		                 urlCorregida
		
		-- Eliminar la / al final
		textoCorregido = textoCorregido:match('(.+)/$') or textoCorregido
		
		return '[' .. urlCorregida .. ' ' .. textoCorregido .. ']'
	end
end

function z.url(frame)
	if not frame or not frame.args then
		return
	end
	
	return z.enlazar(frame.args[1], frame.args[2])
end

--function z.enlacePlano
	-- Ver la plantilla Enlace plano
--	return
--end

-- Ver la función checkurl del módulo de citas.
function z.esValida(url)
	return url:sub(1,2) == "//" or url:match( "^[^/]*:" )
end

return z