def uridefrag(uristring):
    """Remove an existing fragment component from a URI reference string.

    """
    if isinstance(uristring, bytes):
        parts = uristring.partition(b'#')
    else:
        parts = uristring.partition(u'#')
    return DefragResult(parts[0], parts[2] if parts[1] else None)