def norm_path(path, allow_trailing=True):
<EOL>path = _path_re.sub('<STR_LIT:/>', path)<EOL>if path[<NUM_LIT:0>] != '<STR_LIT:/>':<EOL><INDENT>path = '<STR_LIT:/>' + path<EOL><DEDENT>if not allow_trailing and path[-<NUM_LIT:1>] == '<STR_LIT:/>':<EOL><INDENT>path = path[:-<NUM_LIT:1>]<EOL><DEDENT>return path<EOL>
Normalize a route path.  Ensures that the path begins with a '/'.
If `allow_trailing` is False, strips off any trailing '/'.  Any
repeated '/' characters in the path will be collapsed into a
single one.