Skip to content

Commit

Permalink
Safe path test
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Sep 23, 2024
1 parent 6795a59 commit ad663a1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion yarl/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ class URL:
_FRAGMENT_REQUOTER = _Quoter(safe="?/:@")

_UNQUOTER = _Unquoter()
_PATH_UNQUOTER = _Unquoter(ignore="/", unsafe="+")
_PATH_UNQUOTER = _Unquoter(unsafe="+")
_SAFE_PATH_UNQUOTER = _Unquoter(ignore="/%", unsafe="+")
_QS_UNQUOTER = _Unquoter(qs=True)

_val: SplitResult
Expand Down Expand Up @@ -710,6 +711,17 @@ def path(self) -> str:
"""
return self._PATH_UNQUOTER(self.raw_path)

@cached_property
def safe_path(self) -> str:
"""Decoded path of URL.
/ for absolute URLs without path part.
/ (%2F) and % (%25) are not decoded
"""
return self._SAFE_PATH_UNQUOTER(self.raw_path)

@cached_property
def _parsed_query(self) -> List[Tuple[str, str]]:
"""Parse query part of URL."""
Expand Down

0 comments on commit ad663a1

Please sign in to comment.