Parse and Redirect to uri in Javascript Example that could be turned into a button to view user's public ftp where initial page is "http://user.school.edu/":

javascript:(function( {
   var h,i,t;
   h=window.location.hostname;i=h.IndexOf('.school.edu');t=h.substring(0,i);
   window.location.assign("ftp://ftp.school.edu/public/"+t
});


Help me refine this idea, please.
It can also be written in "one line" using regular expression:

window.location = window.location.hostname.replace(
    /^(.*)\.school\.edu$/,
    "ftp://ftp.school.edu/public/$1"
);


I believe in this case regular expression expresses the intent more clearly than using indexOf and string slicing, though tastes may vary.