Skip to content

Commit

Permalink
Merge pull request #766 from Webperf-se/cahce-consistent-key
Browse files Browse the repository at this point in the history
Cache key created for a resource sometimes differ depending context
  • Loading branch information
7h3Rabbit authored Dec 10, 2024
2 parents 2b1f852 + 26e4098 commit f1b7705
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import json
import time
import urllib # https://docs.python.org/3/library/urllib.parse.html
import urllib.parse
import uuid
import re
import os
Expand Down Expand Up @@ -137,6 +138,14 @@ def get_cache_path_for_rule(url, cache_key_rule):
Returns:
str: The generated cache path.
"""

# Parse the URL into components
tmp_parsed_url = urllib.parse.urlparse(url)
if tmp_parsed_url.query is not None and tmp_parsed_url.query != '':
if tmp_parsed_url.query.find('%') != -1:
unencoded_query = urllib.parse.unquote(tmp_parsed_url.query)
url = f"{tmp_parsed_url.scheme}://{tmp_parsed_url.netloc}{tmp_parsed_url.path}?{unencoded_query}"

o = urlparse(url)
hostname = o.hostname
if hostname is None:
Expand Down

0 comments on commit f1b7705

Please sign in to comment.