The function is as follows:
# community URL rewriter function urlRewriter (string url) : string { var string retUrl; if (not $url->starts_with("http://community.livejournal.com/")) { return $url; } # first drop the http://community.livejournal.com/ var int len = $url->length(); $retUrl = $url->substr(33, $len); # now scan the string for the first slash to # get the username part var string comm; var string entry; var int[] possLocations; $possLocations = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; $len = $retUrl->length(); var int j; $j = 0; foreach var int i ($possLocations) { if ($j == 0) { $comm = $comm + $retUrl->substr($i, 1); $entry = $retUrl->substr($i + 1, $len); # replace _ with - as we go if ($comm->ends_with("_")) { $comm = $comm->substr(0, $i); $comm = $comm + "-"; } if ($entry->starts_with("/")) { $j = $i; } } } return "http://" + $comm + ".livejournal.com" + $entry; }