Its not really quadratic in Java. substring(n) returns a new String object that uses the same underlying character array. The cost is just the new String object construction, its quite low.

Most cases this loop runs at most once. Given both of these facts, it is more readable to use the shorter two-line version of the logic than to use the longer version that tries to avoid creating intermediate String objects in the case that additional unnecessary leading slashes are supplied.

Premature optimization being evil and all of that... :-)