I am using a customized BibLaTeX bibliography style in which I use the following macro: \newbibmacro{archive}[1]{\\\textsc{Archived:}\ \url{#1}}.
I use this to format certain urls, it is called from other macros with a string (normally "http://www.somesite.com") as argument. This works fine.
However, for reasons beyond my control, sometimes the string I need to pass to the macro is already in the form "\url{http://www.somesite.com}". This means that my macro then generates \\\textsc{Archived:}\ \url{\url{http://www.somesite.com}}, which of course results in a latex compilation error due to the nested \url.
So, my question is: how can I change the above macro such that it only wraps its argument (#1) in \url if it is not already wrapped that way?
EDIT: MWE's to clarify my problem with egreg's answer
Although my original macro causes compilation problems in case of double wrapped url's, its presence in my bbx file does not break compilation on its own. For example, this compiles fine:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{test.bbx}
\ProvidesFile{test.bbx}
\RequireBibliographyStyle{numeric-comp} %in turn that one requires standard.bbx
\newbibmacro{archive}[1]{\\\textsc{Archived:}\ \url{#1}}
\end{filecontents}
\usepackage[bibstyle=test]{biblatex}
\begin{document}
Blah blah
\end{document}
However, when I put egreg's solution in a bbx file (which is were I want it to be because this macro is part of my custom bibliography style), it causes a compilation error (even if the macro is not called). Hence, this does not compile:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{test.bbx}
\ProvidesFile{test.bbx}
\RequireBibliographyStyle{numeric-comp} %in turn that one requires standard.bbx
\makeatletter
\newbibmacro{archive}[1]{\\\textsc{Archived:} \test@URL#1\@nil}
\def\test@URL{\@ifnextchar\url\test@URL@i\test@URL@ii}
\def\test@URL@i#1\@nil{#1}
\def\test@URL@ii#1\@nil{\url{#1}}
\makeatother
\end{filecontents}
\usepackage[bibstyle=test]{biblatex}
\begin{document}
Blah blah
\end{document}
I guess this due to that \makeatletter/other stuff?
I have never quite understood what that is for :-)

\makeatletterand\makeatother: you don't need them in a.bbxfile. – egreg Feb 7 '12 at 18:31sourcemapfunctionality to regularise your data stream without having to actually edit it. – PLK Feb 7 '12 at 20:28