\newcatcodetable \mytxtcatcodes
\startcatcodetable \mytxtcatcodes
    \catcode`\^^I = 10
    \catcode`\^^M =  5
    \catcode`\^^L =  5
    \catcode`\    = 10
    \catcode`\^^Z =  9
    \catcode`\\   =  0
    \catcode`\{   =  1
    \catcode`\}   =  2
\stopcatcodetable

\def\dosingleasciigroup#1%
  {\pushcatcodetable
   \setcatcodetable \mytxtcatcodes
   \def\next##1{#1{##1}\popcatcodetable}%
   \next}

\def\dosingleasciiargument#1%
  {\pushcatcodetable
   \setcatcodetable \mytxtcatcodes
   \def\next[##1]{#1[##1]\popcatcodetable}%
   \dosingleargument\next}

\def\doquadrupleasciiargument#1%
  {\pushcatcodetable
   \setcatcodetable \mytxtcatcodes
   \def\next[##1][##2][##3][##4]{#1[##1][##2][##3][##4]\popcatcodetable}%
   \doquadrupleargument\next}
   
\def\setasciicommand#1#2%arguments cs
  {\savenormalmeaning{#2}%
   \def#2{#1{\csname normal\strippedcsname#2\endcsname}}}

\setasciicommand\dosingleasciigroup\footnote
\setasciicommand\dosingleasciigroup\hyphenatedurl

% This does not work... possible because the context(...) function is using 
% ctxcatcodes rather than current catcodes.

%\setasciicommand\dosingleasciigroup\dofromurldescription

\setasciicommand\doquadrupleasciiargument\useURL
% Not needed
%\setasciicommand\dosingleasciiargument\from

\startluacode
local references      = structures.references
references.urls      = references.urls      or { }
references.urls.data = references.urls.data or { }

function references.from(name)
    local u = references.urls.data[name]
    if u then
        local url, file, description = u[1], u[2], u[3]
        if description ~= "" then
            -- context.dofromurldescription(description)
            -- AM: Changed this
            tex.sprint(tex.mytxtcatcodes, description)
            -- ok
        elseif file and file ~= "" then
            context.dofromurlliteral(url .. "/" .. file)
        else
            context.dofromurlliteral(url)
        end
    else
        local f = files[name]
        if f then
            local description, file = f[1], f[2]
            if description ~= "" then
                context.dofromfiledescription(description)
            else
                context.dofromfileliteral(file)
            end
        end
    end
end

\stopluacode

\starttext
\hyphenatedurl{http://www.google.com/some%20thing}
test \footnote{A footnote with a \bold{url} \hyphenatedurl{http://www.google.com/some%20thing}}

\useURL[one][http://www.google.com/some%20thing][][http://www.google.com/some%20thing]
\from[one]

\stoptext
   
