💭П
Size: a a a
💭П
KK
SZ
D
import re
urlpath_regex = r'^([^\/]*(?:\/\/)?[^?\/=]+\/?(?:[^?\/=]+\/?)*)(?:\?[^?\/]+)*$'
def get_path(url):
try:
return re.match(urlpath_regex, str(url).lower()).group(1).rstrip('/')
except AttributeError:
return None
print(
get_path('http://example.ru/page1/page2?z=5&x=7') == get_path('http://ExampLe.ru/page1/page2/')
)
RB
D
RB
💭П
БС
import re
urlpath_regex = r'^([^\/]*(?:\/\/)?[^?\/=]+\/?(?:[^?\/=]+\/?)*)(?:\?[^?\/]+)*$'
def get_path(url):
try:
return re.match(urlpath_regex, str(url).lower()).group(1).rstrip('/')
except AttributeError:
return None
print(
get_path('http://example.ru/page1/page2?z=5&x=7') == get_path('http://ExampLe.ru/page1/page2/')
)
RB
SZ
RB
D
from urllib.parse import urlparse
def get_path(url: str)-> str:
return url.split('//')[0] + urlparse(url.lower()).path.rstrip('/')
print(
get_path('https://example.ru/page1/page2?z=5&x=7') == get_path('https://ExampLe.ru/page1/page2/')
)
A🍊
A🍊
in