Module:Citation/CS1/Links:修订间差异

zhwiki>Shizhao
小 fix test
 
IdleTap-bot​(留言 | 贡献)
导入自求闻百科
 
第311行: 第311行:
local function make_external_link( URL, label, source )
local function make_external_link( URL, label, source )
local error_str = "";
local error_str = "";
local domain;
local path;
if not is_set( label ) then
if not is_set( label ) then
label = URL;
label = URL;
第327行: 第325行:
throw_error( 'bad_url_no_origin' );
throw_error( 'bad_url_no_origin' );
end
end
end
domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$'); -- split the URL into scheme plus domain and path
if path then -- if there is a path portion
path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'}); -- replace '[' and ']' with their percent-encoded values
URL = table.concat ({domain, path}); -- and reassemble
end
end
return table.concat({ "[", URL, " ", safe_for_url( label ), "]", error_str });
return table.concat({ "[", URL, " ", safe_for_url( label ), "]", error_str });