Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a22ec9b12966eefa

Jump to content

Module:Domain handler

Permanently protected module
From Wikipedia, the free encyclopedia

local p = {}

function p.getTopLevelDomain(frame)
    local args = frame.args
    local domain = args.domain or args[1]
    local context = args.context or "domains"

    if domain and domain ~= "" then
        domain = mw.text.trim(domain):lower()
        domain = "." .. domain:gsub("^%.", "")

        local category = "Category:Redirects from " .. domain ..
                         (context == "domains" and " domain names" or " URLs")

        if mw.title.new(category).exists then
            return " " .. domain
        end
    end

    local currentTitle = mw.title.getCurrentTitle().text
    currentTitle = currentTitle:lower():gsub("^https?://", "")
    currentTitle = currentTitle:match("^([^/]+)") or currentTitle

    local topLevelDomain = currentTitle:match("(%.[^.]+)$")

    if topLevelDomain then
        local category = "Category:Redirects from " .. topLevelDomain ..
                         (context == "domains" and " domain names" or " URLs")

        if mw.title.new(category).exists then
            return " " .. topLevelDomain
        end
    end

    return ""
end

function p.adjustTitleCapitalization(frame)
    local title = mw.title.getCurrentTitle().text
    local lowercaseParameter = (frame.args.lowercase or ""):lower()

    if lowercaseParameter == "yes" then
        return title:sub(1,1):lower() .. title:sub(2)
    end
    if lowercaseParameter == "no" then
        return title
    end

    return title:sub(2):find("%u") and title or title:sub(1,1):lower() .. title:sub(2)
end

return p