//
// Created       : 2006 Aug 12 (Sat) 14:56:41 by Harold Carr.
// Last Modified : 2008 May 27 (Tue) 10:36:52 by Harold Carr.
//

package org.openhc.trowser.gwt.common;

public abstract class Util
{
    public static String substringAfterLastSlashOrFirstSharp(final String x)
    {
	int indexOfLastSlashOrFirstSharp = 0;
	int i;
	for (i = 0; i < x.length(); ++i) {
	    if (x.charAt(i) == '/' || x.charAt(i) == '#') {
		indexOfLastSlashOrFirstSharp = i;
	    }
	}
	final String result = x.substring(indexOfLastSlashOrFirstSharp + 1);
	// If it ends in a slash then remove the ending slash and try again.
	if (result.length() == 0) {
	    return substringAfterLastSlashOrFirstSharp(
                       x.substring(0, x.length()-1));
	} else {
	    return result;
	}
    }
}

// End of file.

@@ -91,24 +91,24 @@
 ay 2
-7 (Tue) 10:36:52
+8 (Wed) 07:51:01
  by 
@@ -458,16 +458,108 @@
    %7D%0A%09%7D%0A
+%09if (indexOfLastSlashOrFirstSharp == 0) %7B%0A%09    // It doesn't contain any.%0A%09    return x;%0A%09%7D%0A
 %09final S

["If the string doesn't contain a slash or sharp, just return it.\n", ""]