def to_public_dsn(url):
    """Removes the basicauth password from a dsn url::
        
          >>> dsn = 'https://user:password@app.getsentry.com/1'
          >>> to_public_dsn(dsn)
          'https://user@app.getsentry.com/1'
      
      Works with schemeless urls too::
      
          >>> dsn = '//user:password@app.getsentry.com/1'
          >>> to_public_dsn(dsn)
          '//user@app.getsentry.com/1'
      
      Passes through urls without a `@`::
      
          >>> to_public_dsn('//user:password.app.getsentry.com/1')
          '//user:password.app.getsentry.com/1'
      
    """
    parts = url.split('@')
    if len(parts) < 2:
        return url
    subparts = parts[0].split(':')
    if len(subparts) > 1 and not '//' in subparts[-1]:
        parts[0] = ':'.join(subparts[:-1])
    return '@'.join(parts)
