Skip to content

Commit

Permalink
add the function get_query_arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaCharles committed Dec 22, 2023
1 parent 88054df commit 4c13b7b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ural/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def quote(string, safe="/"):
unshadowed_quote = quote



def safe_urlsplit(url, scheme="http"):
if isinstance(url, SplitResult):
return url
Expand Down Expand Up @@ -78,6 +79,32 @@ def urlpathsplit(url):
return pathsplit(parsed.path)


def get_query_arguments(url,key):
splitted=pathsplit(url)
last=splitted[-1]
add=len(key)+1

if "?"+key in last :
if last.index( "?"+key)+add == len(last) :
return True
elif last[last.index( "?"+key)+add]== "=":
if last.index( "?"+key)+add+1==len(last):
return ""
else :
coupe=last[last.index( "?"+key)+add : ]
if "&" in coupe :
next_et= coupe.index("&")
value=coupe[1:next_et]
return value
else:
value=coupe[1:]
return value


else :
return None


SLASH_SQUEEZE_RE = re.compile(r"\/{2,}")


Expand Down

0 comments on commit 4c13b7b

Please sign in to comment.