Skip to content

Commit

Permalink
Use yarl in is_same_url()
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Mar 1, 2024
1 parent 94eae70 commit 1610bf9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dandi/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pathlib import Path

import click
from yarl import URL

from .consts import DRAFT, ZARR_EXTENSIONS, DandiInstance, dandiset_metadata_file
from .dandiapi import DandiAPIClient, RemoteAsset, RemoteDandiset
Expand Down Expand Up @@ -246,5 +247,8 @@ def find_local_asset(filepath: str) -> tuple[str, str]:


def is_same_url(url1: str, url2: str) -> bool:
# TODO: Use a real URL library like furl, purl, or yarl
return url1.rstrip("/") == url2.rstrip("/")
u1 = URL(url1)
u1 = u1.with_path(u1.path.rstrip("/"))
u2 = URL(url2)
u2 = u2.with_path(u2.path.rstrip("/"))
return u1 == u2

0 comments on commit 1610bf9

Please sign in to comment.