\nofiles
\documentclass{article}
\usepackage[spanish]{babel}
\usepackage[bookmarks=false]{hyperref}
\listfiles

\makeatletter
\def\TEST{%
  \if@safe@actives
    \PackageError{TEST}{%
      Wrong setting of \expandafter\string
      \csname if@safe@actives\endcsname
    }\@ehc
  \else
    \typeout{* TEST: ok}%
  \fi
}
\makeatother

\begin{document}
A~test.
\href{http://www.url.net/}{A~test\TEST}.
\end{document}
