def query( otherwise, uri ):
    """Extract the query component."""
    first = uri.find('?')
    if -1 == first:
        return otherwise
    last = uri.find('#')
    if -1 == last:
        return uri[1+first:]
    elif last < first:
        return uri[1+first:last]
    return otherwise