#K` 4 d dl Z d dlmZmZmZmZmZmZ ddlm Z ddl
mZmZ ddl
mZ ddlmZ ddlmZ d Zerdd
lmZ ed Zded
edeeef fdZdedefdZeee gee f Zdddeddedededee def
dZdddefdZdS ) N)
TYPE_CHECKING AwaitableCallableTupleTypeTypeVar )Handler)HTTPPermanentRedirect _HTTPMove)Request)StreamResponse)SystemRoute)
middlewarenormalize_path_middleware)Application_Funcrequestpathreturnc K | | }| j j | d {V }||_ |j d|fS d| fS )N)rel_urlTF)cloneapprouterresolve_match_infohttp_exception)r r alt_request
match_infos y/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib64/python3.11/site-packages/aiohttp/web_middlewares.py_check_request_resolvesr" si -----K{)11+>>>>>>>>J(K ([ '> fc d| _ | S )Nr )__middleware_version__)r$ s r! r r ! s AHr# TF)append_slashremove_slash
merge_slashesredirect_classr' r( r) r* c o }|s
J d t dt dt dt f fd }|S )a Factory for producing a middleware that normalizes the path of a request.
Normalizing means:
- Add or remove a trailing slash to the path.
- Double slashes are replaced by one.
The middleware returns as soon as it finds a path that resolves
correctly. The order if both merge and append/remove are enabled is
1) merge slashes
2) append/remove slash
3) both merge slashes and append/remove slash.
If the path resolves with at least one of those conditions, it will
redirect to the new path.
Only one of `append_slash` and `remove_slash` can be enabled. If both
are `True` the factory will raise an assertion error
If `append_slash` is `True` the middleware will append a slash when
needed. If a resource is defined with trailing slash and the request
comes without it, it will append it automatically.
If `remove_slash` is `True`, `append_slash` must be `False`. When enabled
the middleware will remove trailing slashes and redirect if the resource
is defined
If merge_slashes is True, merge multiple consecutive slashes in the
path into one.
z#Cannot both remove and append slashr handlerr c j K t | j j t rg }d| j v r$| j dd \ }}d|z }n d}| j }r)| t j dd| r2| j
d s| |dz
r7| j
d r| |d d r.r,| t j dd|dz r5
r3t j dd| }| |d d |D ]F}t j dd| }t | | d {V \ }} |r | j |z G || d {V S )N?r z//+/z^//+)
isinstancer router raw_pathsplitappendresubr endswithr" )r r, paths_to_checkr querymerged_slashesresolvesr' r) r* r( s r! implz'normalize_path_middleware.