Module:Utils

local p = {}

function p.getHostFromURL( frame ) s = frame.args[1] return (s.."/"):match("://(.-)[:/]") end

function p.stripAPIURL( frame ) s = frame.args[1] return s:match("https?://(.+)") end

function p.getBranchNumber( frame ) s = frame.args[1] return s:match("%.(%d+)") end

function p.getExtensionVersions( frame ) extensionName = frame.args[1] local query = { 'Has extension::Extension:'..extensionName..'', 'Has extension version::!~*MLEB*', '?Has extension version=extVersion', '?Has MediaWiki version=mwVersion' }	query.limit = 5000

local result = mw.smw.ask( query ) return mw.dumpObject(result) --[[

local extVersions = {} local mwVersions = {} if result and #result then for _, data in pairs( result ) do			if data.extVersion then extVersions[data.extVersion] = data.extVersion end if data.mwVersion then mwVersions[data.mwVersion] = data.mwVersion end end end

local extKeys = {} for k in pairs(extVersions) do		table.insert(extKeys, k)	end table.sort(extKeys)

local mwKeys = {} for k in pairs(mwVersions) do		table.insert(mwKeys, k)	end table.sort(mwKeys)

local output = '' local index = 1 for k = #extKeys, 1, -1 do output = output .. extKeys[k] .. '\n' index = index + 1 if index > 5 then break end end output = output .. '\n'

index = 1 for k = #mwKeys, 1, -1 do output = output .. mwKeys[k] .. '\n' index = index + 1 if index > 20 then break end end

return output ]] end

return p