def trim_url(link):
 link_text = link
 if (len(link_text) > TRIM_URL_LENGTH):
  scheme_index = (link.rfind('://') + 3)
  last_slash_index = link.rfind('/')
  text_to_replace = link[scheme_index:last_slash_index]
  link_text = link_text.replace(text_to_replace, '...')
 return link_text

def trim_url ( link ) : link_text = link if ( len ( link_text ) > TRIM_URL_LENGTH ) : scheme_index = ( link . rfind ( '://' ) + 3 ) last_slash_index = link . rfind ( '/' ) text_to_replace = link [ scheme_index : last_slash_index ] link_text = link_text . replace ( text_to_replace , '...' ) return link_text
trims link if its longer than trim_url_length chars .