# Automatic line breaking of camel case within \url

I would like to break camel case text that is handed to the \url{} macro of url.sty. The solution here does not work for text in captions, so it seems, ans in particular does not work for \url{}.

Is there a way to break the camel case as in:

\documentclass{article}

\usepackage{url}

\begin{document}
\noindent{}Here some text, and
and then some more text to indicate the text width, showing that
the URL should break earlier.
\end{document}

\documentclass{article}

\usepackage{url}

\makeatletter
\def\camelurl{%
\count@a
\loop
\mathcode\count@"8000
\uccode\~\count@\uppercase{\edef~{\mathchar\the\count@\noexpand\breakifupper}}%
\ifnum\count@<\z
\repeat}

\def\breakifupper#1{%
\ifcat .\noexpand#1%
\ifnum#1>40
\ifnum`#1<91
\penalty\z@
\fi\fi\fi
#1%
}

\makeatother

\begin{document}
\noindent{}Here some text, and