Modul:URLutil: Unterschied zwischen den Versionen

2017-11-01
w>PerfektesChaos
(2017-04-19)
w>PerfektesChaos
(2017-11-01)
Zeile 1: Zeile 1:
local URLutil = { suite  = "URLutil",
local URLutil = { suite  = "URLutil",
                   serial = "2017-04-19" };
                   serial = "2017-11-01" };
--[=[
--[=[
Utilities for URL etc. on www.
Utilities for URL etc. on www.
Zeile 40: Zeile 40:
IPv6 URL (bracketed) not yet implemented; might need Wikintax escaping anyway.
IPv6 URL (bracketed) not yet implemented; might need Wikintax escaping anyway.
]=]
]=]
URLutil.getURIScheme = function ( uri )
    if type( uri ) == "string" then
        local prot, colon, slashes = uri:match( "^%s*([a-zA-Z]*)(:?)(/?/?)" )
        if #colon == 1 and #prot >= 2 then
            return prot:lower()
        elseif #slashes == 2 and #prot == 0 then
            return "//"
        end
    end
    return false
end -- getURIScheme()




Zeile 341: Zeile 327:
                         sP = decodeComponentPercent( sP, "P" )
                         sP = decodeComponentPercent( sP, "P" )
                     end
                     end
                     r = r:sub( 1,  j - 1 )
                     r = r:sub( 1,  j - 1 )
                 end
                 end
             elseif j then
             elseif j then
Zeile 365: Zeile 351:
             end
             end
         end
         end
         r = r:gsub( "%[", "%%5B" )
         r = r:gsub( " ",  "%%20" )
            :gsub( "%[", "%%5B" )
             :gsub( "|",  "%%7C" )
             :gsub( "|",  "%%7C" )
             :gsub( "%]", "%%5D" )
             :gsub( "%]", "%%5D" )
Zeile 807: Zeile 794:
     return false
     return false
end -- isProtocolAccepted()
end -- isProtocolAccepted()
URLutil.isProtocolMW = function ( prot )
    return isProtocolAccepted( prot,
                              " http https ftp ftps ssh sftp irc ircs xmpp sip sips gopher telnet nntp worldwind mailto tel sms news svn git mms bitcoin magnet urn geo " )
end -- URLutil.isProtocolMW()




Zeile 917: Zeile 897:
local p = {}
local p = {}


function p.getURIScheme( frame )
    return URLutil.getURIScheme( frame.args[ 1 ] ) or ""
end
function p.getAuthority( frame )
function p.getAuthority( frame )
     return URLutil.getAuthority( frame.args[ 1 ] ) or ""
     return URLutil.getAuthority( frame.args[ 1 ] ) or ""
Zeile 1.016: Zeile 993:
function p.isMailLink( frame )
function p.isMailLink( frame )
     return URLutil.isMailLink( frame.args[ 1 ] ) and "1" or ""
     return URLutil.isMailLink( frame.args[ 1 ] ) and "1" or ""
end
function p.isProtocolMW( frame )
    return URLutil.isProtocolMW( frame.args[ 1 ] ) and "1" or ""
end
end
function p.isProtocolDialog( frame )
function p.isProtocolDialog( frame )
Zeile 1.040: Zeile 1.014:
function p.wikiEscapeURL( frame )
function p.wikiEscapeURL( frame )
     return URLutil.wikiEscapeURL( frame.args[ 1 ] )
     return URLutil.wikiEscapeURL( frame.args[ 1 ] )
end
function p.getURIScheme( frame )
    return ""
end
function p.isProtocolMW( frame )
    return ""
end
end
function p.failsafe()
function p.failsafe()
Anonymer Benutzer